How many 5 volt servos can I run off my arduino?

I'm kind of curious about how this all works. I know each pin supplies 5 volts of electricity which is used to power whatever it's hooked up to it. You can easily power LEDs or other things from as many pins as you need, each pin outputting 5 volts of electricity. If my servos only require 5 volts to run, shouldn't it be possible to run as many 5 volt servos as there are pins? I'm guessing this isn't possible because every tutorial insists on using an alternate power source. I've run two continuous rotation servos from one Arduino without any trouble. For my next project, I need five. Will I need to wire up a battery. I'm only asking because I've been having trouble wiring batteries to my circuit (I've got another topic for this, I just want an answer to my original question). Thanks!

The biggest thing to keep in mind is that the pins on the Arduino are signal, not power. The servo gets its power from the battery directly and the data line goes to the Arduino.

Can you describe how you hooked the 2 servos to your board?

The biggest thing to keep in mind is that the pins on the Arduino are signal, not power. The servo gets its power from the battery directly and the data line goes to the Arduino.

Can you describe how you hooked the 2 servos to your board?

I solved my battery problem so this doesn't really matter anymore, but I had them hooked up to a BOE shield. I guess they weren't actually wired directly to my Arduino like I had thought.

Electricity is made up of two components, the voltage, and the current.

A device requires a specific voltage to operate at - any higher than this and the device could blow up, any lower and the device won't work right.

Your servos require 5V to operate. Any more, and the coils could burn out. Any less, and the motors won't be able to turn well enough.

Then there is the current. This, coupled with the voltage, defines the amount of "power" a device consumes. A device has a current requirement, which is how much current it wants to pull from the power source. A power source can only supply up to a limited amount of current, so if your device tries to pull more than the available current from the power source it could break the power source. A device can happily pull less than the power source's current limit.

This is where an Arduino IO pin and a battery differ vastly. A battery has a much higher current limit than an Arduino IO pin. Some batteries (such as car batteries) are capable of delivering many hundreds of amps of current. Small batteries like AA, AAA, C, D, PP3, etc can supply much lower currents, but are still many more times more powerful than an Arduino IO pin.

An Arduino is capable of supplying no more than 40mA of current through any one IO pin, and the total current drawn by the ATMega328P chip (including what is drawn from its IO pins) must not exceed 200mA. LEDs typically draw around 20 to 25mA, so they are fine to connect to an IO pin for their power (with a suitable resistor to limit their current - they have no internal resistance of their own), but anything more powerful, such as a relay, or a motor, must be powered by some other power source. This could be the Arduino's 5V pin, if you don't need more than a few hundred mA, or an external battery or power supply.

Servos are slightly different to other motors in that they have a separate control line to their power lines, so you can connect the power up to an external source and control them through an Arduino IO pin.

So yes, using an external power source to provide the power to the servos, you could theoretically control as many servos as there are IO pins. You could theoretically control many many more by adding IO expanders and other controller chips.

Servos take large current surges (of the order of an amp or more), and cannot be reliably powered from the Arduino 5V output (let alone an I/O pin). It'll sort of work but the current surges may overload the regulator and cause the 5V to drop and reset the processor. This is a common problem - don't power motors or servos from the 5V pin. Use a separate supply if possible - this also reduces the risk of inductive voltage spikes causing damage.

If you want to power the Arduino and servos/motors from a single supply you really should ensure:

  1. Power source can take the maximum load currents from the motors/servos without dropping voltage appreciably. So you'll need to test this or know the stall currents of everything. A sizable lead-acid battery is pretty robust at current spikes, and LiPo's too. In such a set-up a fuse for the supply becomes advisable.

  2. Power source is between 7V and 12V so can power the Arduino via Vin (and the Arduino's regulator can provide protection from voltage spikes). Or if more than 12V a suitable regulator or DC-DC converter is used to drop the voltage to the 7--12V range.

There are other approaches, such as using a large amount of decoupling on the Arduino to cover the brief power-outages (possibly including a diode to prevent reverse current flow).

If you use a square 9V battery to power a servo then it won't last very long. This sort of battery is not suited for driving motors.

Thanks everyone for your answers! I ended up figuring out my battery problem. I'm using a 16 channel pwm servo driver from Adafruit hooked up to a 6 volt battery to power my servos.