Powering servo with makeshift battery pack

I have gotten my Arduino servo (4.8V-6.0V) working fine while plugged into my computer, but I am trying to make the mechanism I've made to be portable. I am just using the sweep action on the servo and a button to stop it. Is it possible to save programs onto the Arduino so it doesn't have to be plugged into the computer? And if so, would I be able to power the servo with 4 AA batteries connected in series (4 - 1.2V AA batteries or 4 - 1.5V AA batteries) since it would be 4.8V total or 6.0V total which is what the servo requires? I am concerned about damaging any of my components whether it be the servo or the board. If all of that is possible, would I need any resistors or any other components? Thank you.

When you upload code to the Arduino, the code is stored in flash memory and stays until you upload new code. You could then power the servos with the 4.8v-6v pack. However, you should power the Arduino with either 5v from a USB adapter or 12V from a wall adapter, using either the 2.1mm plug for 12V or the USB for the 5V.
The attached picture is for a Raspberry Pi, but the Arduino can be used similarly. Just make sure to have the ground of the battery pack connected to the Arduino ground.

Thank you for the fast reply. Okay so no resistance is needed, right? And would a capacitor be the only other part in this other than the battery and servo?

No resistance is needed. You do need a separate power supply for the Arduino. Otherwise the servos will create power spikes which will cause the Arduino to behave erratically.

Could I just make another battery pack for the Arduino as well? Another 4.8-6.0V one? Or would I be damaging the board by using a not so reliable voltage source

You should use either a regulated 5v supply or a 8-12 volt supply/battery. The 5v supply can be plugged into the 5V pin on the Arduino, and an 8-12V supply can be plugged into the barrel jack next to the USB port on the Arduino.

Sadly I don't have a cord for the barrel jack so I wouldn't be able to use that. Would a 9V battery with some resistance to bring it down to 5V then connected to the 5V port on the Arduino be considered a regulated power supply? And if that is even possible, how would I calculate the required resistance because I am not sure of how to find the current for the equation. Thanks

Resistance is not good.

  1. It wastes power
  2. The voltage drop changes depending on the current drawn.

Do you have a USB power bank? You could use that to power the Arduino over USB.
You could connect the 9v battery to the Vin pin on the Arduino.

I don't have a power bank either, but I do have a 9V. The 9V positive in the Vin pin and negative in the ground? I've never used that pin before and want to make sure it won't damage the board.

Yup, that's how you do it :slight_smile:
Make sure to keep the grounds connected.

So for the arduino and the 9V its just the negative to ground and posive to Vin, but how would the servo be setup on the breadboard

For the servo, you can use a 4xAA (6V) battery pack or a 5 to 6V power brick.

Connect the servo power positive to the servo positive, the servo input to the appropriate Arduino output pin, and connect the servo power negative to the servo ground AND the Arduino ground.

You should never attempt to power a motor, servo, relay or solenoid from the Arduino 5V output.