How to Power Arduino with Battery: Simple Guide
You can power an
Arduino using a battery by connecting a suitable battery pack to the Vin pin or the barrel jack input. Use batteries that provide 7-12V for stable operation, and ensure correct polarity to avoid damage.Syntax
To power an Arduino with a battery, connect the battery's positive terminal to the Vin pin or the barrel jack, and the negative terminal to GND. The Arduino's onboard voltage regulator will convert the battery voltage to the 5V needed.
Vin: Input voltage pin (7-12V recommended)GND: Ground connectionBarrel jack: Alternative power input (7-12V)
plaintext
Battery Positive (+) ---> Vin or Barrel Jack Battery Negative (-) ---> GND
Example
This example shows how to power an Arduino Uno with a 9V battery connected to the Vin pin and GND. The Arduino will blink the built-in LED to confirm it is powered correctly.
arduino
void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off delay(1000); // wait for a second }
Output
The built-in LED on pin 13 blinks on and off every second.
Common Pitfalls
Common mistakes when powering Arduino with batteries include:
- Using batteries with voltage lower than 7V, causing unstable operation.
- Connecting battery positive to
5Vpin directly, which can damage the board. - Reversing polarity, which can permanently damage the Arduino.
- Not considering battery capacity, leading to short run time.
Always use the Vin or barrel jack for battery input and check polarity carefully.
plaintext
Wrong way:
Battery Positive (+) ---> 5V pin
Battery Negative (-) ---> GND
Right way:
Battery Positive (+) ---> Vin or Barrel Jack
Battery Negative (-) ---> GNDQuick Reference
Tips for powering Arduino with batteries:
- Use 7-12V battery packs (e.g., 6xAA batteries or 9V battery).
- Connect to
Vinpin or barrel jack, never directly to 5V pin. - Check battery polarity before connecting.
- Consider battery capacity (mAh) for desired runtime.
- Use rechargeable batteries for cost efficiency and environment.
Key Takeaways
Power Arduino by connecting battery positive to Vin or barrel jack and negative to GND.
Use batteries with 7-12V for stable and safe operation.
Never connect battery directly to 5V pin to avoid damage.
Check battery polarity carefully before powering Arduino.
Consider battery capacity to ensure sufficient runtime.