I have two continuous servos connected to my Uno, and I'm running this code on it:




int i;
while(1) {

When I run the code, the wheels stop for three seconds (91 and 102 are the zero values for these servos) then they spin for three seconds, then the left servo stops, but the right one only slows down about half way, it doesn't stop, even though the exact same number is used as before.

I can't figure out why this is?

  • My first piece of advise would be to dump that function (without the "while(1)" part) into the end of setup() and see what happens. Mar 5, 2015 at 16:47
  • Same effect unfortunately
    – Owen
    Mar 5, 2015 at 16:54
  • Have you swapped the motors round to check it's not the hardware? If that's the same try swapping the order of the final leftservo/rightservo commands. Mar 5, 2015 at 16:59
  • I have added a delay of 100 ms between servo writes, and that seems to have helped, the zero point for the right servo seems to have moved now though, 106 moves slowly counter-clockwise, and 107 moves slowly clockwise
    – Owen
    Mar 5, 2015 at 17:08
  • 1
    I'm leaning toward the conclusion that the problem is with the hardware, probably some noise effecting the servo. Are the motors running on a different supply to the Uno? Have you made sure the grounds are tied together? Have you tried some decoupling caps on the servo power supply? If you have access to one take an oscilloscope to the circuit and check for unwanted noise. Mar 5, 2015 at 17:56

1 Answer 1


Issue was fixed by adding a delay of 100ms between servo writes, smaller values may work, but I haven't tried yet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.