Arduino Uno Servo Programming help, and advice.


Here is my project: I have an Arduino Uno board that controls 2 servos. The 2 Servos sit on the left and right side of the robot, they are continuous rotating servos. It robot leans on ball point in the middle forward tip of the robot.

My goal is to program pre-determined paths. I been attempting to use code like this to make that happen:

myservol.write(100); myservor.write(100); delay(450);

That will normally make the robot turn 90 degrees to the left. However it is not very accurate. Factors come to the play including the battery, when it dies down a bit 90 degrees turns into 80, because the Servos move slower.

I can only see two solutions: (Open to more ideas)

Solution 1: Somehow get the voltage to stay at an exact constant. (Not sure how, its current getting its power from the 5v power pin on the Arduino board.)

Solution 2: Come up with a more accurate way to code, not one that works off time. (Again open to suggestions im not sure how to do this either)

Im open to any solution thoughts or new ideas!

First, do not power servos from the Arduino 5V supply. A pack of 4AA batteries is an adequate power supply. Connect the servos + input to the battery pack +, connect the ground of the servo and Arduino ground to the - of the battery. If you want precision in the turns you could put encoders on the wheels so you know where they really are (versus a timed, inaccurate, run).