Let's Make Robots!

Servos misbehaving with arduino

First post here! Hello all.

I've built a robot (not my first) using 5g microservos, and I've just started playing around with the programming. I've got 8 servos connected to an Arduino Mega but I'm only working with 4 right now. These 4 servos are being powered through the 5v line on the arduino. I set up a simple code to have 4 stages of the motion of the robot. Each one has 4 servo position writes, one for each of the servo, then a delay of 1000, then it goes to the next stage. The problem is, once it gets to the 3rd step, it sets to those positions fine, but between the third step and the fourth step it doesn't do anything right. The servos set to seemingly random positions at 1 second intervals (even the ones that I haven't written to any values yet move!). They will set to these different positions anywhere from 1-3 times and then it goes to stage 4. Anyone know what could be going on here?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The code was as simple as it gets, haha. Bajdi was right, I set up a second usb power line for it and it worked fine. Now I just need to get the feet bigger so this thing can balance right. I'll post it as a robot once things work out better.

Maybe a look at your code would help out here.

Even with just 4 5g microservos? Crap, haha, I was hoping that they wouldn't be even close to too much for the arduino to handle. Thanks

These 4 servos are being powered through the 5v line on the arduino.


The regulator on the Arduino Mega can't handle 4 servos, you have to be lucky to power one... Use a seperate power supply for the servos with a common ground with the Arduino and your problems will be solved.

Please read this: http://rcarduino.blogspot.be/2012/04/servo-problems-with-arduino-part-1.html