Hi all. I'm trying to control just one continuous rotation servo motor (Feetech FS5106R) with an Arduino Due. I am powering both the Arduino and the motor with a 5V external power supply. The servo is connected at PWM pin 9. Here is my code:
#include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(9); //pin number
}
void loop() {
myservo.writeMicroseconds(1450);
delay(3000);
myservo.writeMicroseconds(1800);
delay(1000);
myservo.writeMicroseconds(1100);
delay(1000);
myservo.detach();
}
Once I get this to work how I want, I'll expand it to how I really want it. But basically I'm just looking to rotate it clockwise for a time, stop for a time, counterclockwise for a time, etc, etc. When I run this code, it seems to get stuck in the first three lines of the loop code. The motor remains stationary for 3 seconds, rotates CW for a second, remains stationary for 3 seconds, rotates CW for a second, and so on, without ever rotating CCW. It took a little trial and error to find 1450 as the stopped value, but that is the correct one. How do I fix this?