Hello Everyone.
I wrote a code for my Windows Blinds. The project involves Continuous Servo.
The below code makes servo turn in right directions but it never stopes to run. Any ideas od how to fix it?
//Create servo object to control a servo
Servo myServo;
int posCurrent;
void setup()
{
//Attaches the servo on pin D0 to the servo object
myServo.attach(D0);
posCurrent = 0;
//Register our Particle to control the servo
Particle.function("openBlinds", openBlinds);
Particle.function("closeBlinds", closeBlinds);
}
void loop()
{
}
int openBlinds(String command)
{
//Particle.publish("Position", "currently at" + posCurrent);
myServo.write(10); //clockwise slow
delay(30000);
for(int pos = 10; pos > 0; pos -= 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myServo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
//done
return 1;
}
int closeBlinds(String command)
{
myServo.write(-90); //counter clockwise slow
delay(30000);
for(int pos = -90; pos < 0; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myServo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
//done
return 1;
}