I am trying to get a servo to move to 2 positions. Simple enough. I made a function, specify the angle, servo is to move there.
Simple enough right?
Well, not quite. Have a look at this video and see what is happening:
The code:
Servo myServoName;
int pos = 0;
void setup() {
myServoName.attach( A5 );
Spark.function("setpos", setPosition);
Spark.variable("getpos", &pos, INT);
}
void loop() {
/*
myServoName.write(0);
delay(1000);
myServoName.write(180);
delay(1000);
*/
}
int setPosition(String posValue) {
pos = posValue.toInt();
myServoName.write(pos);
return 0;
}
The other servo works just fine.
Any ideas?