Let's Make Robots!

Arduino questions


i'm from germany and i'm trying to build my first Robot with the arduino Platform.

I've desided to build my own shild for the arduino.

It should be able to drive two motors and to connect 4 -5 servos to the arduino.

The first problems with the L293D Motordriver are solved and I've done that it works and avoids objects.

Today my servos arrived and i tested my shield with the servos.

and then the first problem:

the servo only work on Pin9 and 10. so i looked for the reason and recognized that in the servo lib of arduino its only possible to connect servos on 9 and 10. so i looked for another lib.. i found some=) but its not as easy as the standardlib.. http://www.arduino.cc/playground/ComponentLib/Servo

ok. and when I familiarized myself with the code the servo worked. but how long. now the arduino resets. probably because the servos need more recources.

My questin now is, if somebody now more concret why the µC resets and how its possible to connect 4 servos.

Pin 5,6,9,10 are reserved for the motors 



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
I havent used an Arduino but it is possible that using that many servos takes too much power away from it and causes it to brown out or reset due to lack of power. If you need to control that many servos put them on a different power source. Just remember to tie the grounds together or it won't work.

Check out the MegaServo lib from arduino.cc: http://www.arduino.cc/playground/Code/MegaServo

I never used it but it can control up to 12 servos. If you don't want to do that, maybe invest in a serial servo driver like the Lynxmotion SSC-32: http://www.lynxmotion.com/Product.aspx?productID=395&CategoryID=52 which can control up to 32 sevos by having the arduino send serial commands with pins 0 & 1. 

 About the Arduino resetting, you need a separate power supply for your motors and servos. 

Are you running everything from a single power supply? It could be that the servos are causing the battery voltage to drop too low.

Also are you using analogWrite functions for PWM motor control, or just straight up on/off? If not the MegaServo library is better because it takes care of the refreshing automatically where as the one you linked requires you to refresh manually every 50ms. However it uses the 16 bit timer which is also used by analogWrite.

Thomas beat me to it!

Curse you Thomaaaasssss....ss...

I really recommend the MegaServo libary, a very good solution for more servos or servos on non PWM pins.

hi, i've just tested the mega servolib.

#include <MegaServo.h>
MegaServo Servo1;

void setup() {

  Servo1.attach(3, 800, 2200);


void loop() {




its easyer to use.

but the same problem. restarts when motors drive (first time) and the restarts while turning the switch.

i think its the batterie's low voltage(9V). now its about 8V. perhaps the arduino now shut down.

i will recharge the akku and write again.



thanks for the lib.


You didn`t answer the question from earlier. Are you running everything from a single 9v battery?

Servos should really run from 4.8 to 6 volts, not 9 volts. The little 9 volt batteries can barely supply enough current to run the Arduino, the servos need something bigger but less voltage, like 4 AA rechargable batteries.

You could use 2 packs but connect the 2 grounds (negatives) together.

you usually have to connect two batteries to drive a bot with arduinoplatform? i tryed with one.

9V-Block (+) to arduino and pin8 of L293D

and (-) to Ground.

the servos are directly connected to the arduino.

now. the robot restarted also when i disconnected the servo.. it worked before.. so it must be the low bat..

can somebody tell me why it should not working as i connected it.

i don't want to connect two seperate batteries. not only because of the space.


ah.. and is it possible to tell the arduino not to drive when plugged in with usb? would be fine.


Tanks for your answers. I love LMR

The 9 volt battery is only capable of a small amount of current. The Arduino only requires a small amount, so it can run on the 9 volt for a while just fine by itself. Servos require a lot more current, as they are physically moving something more than electrons. And servos are only rated to run off 4.8 volts to 6 volts, higher voltages can destroy them. It sounds like your shield has the servos powered from the regulated 5 volts of the Arduino, not directly to the 9 volt. If you posted the circuit, it might help. If you want to run off one battery, try running 4 AA batteries, as it will last longer than the 9 volt.

Yes, it is possible to run the Arduino on the USBV< and I have run 2 small servos with it too on USB. USB can deliver up to 500 mA at 5 volts.  But servos really require a strong battery pack to supply them.