Powering Microcontrollers

How to Power an Arduino With a Power Supply (Plus a Soft Power Switch)

Learn the four ways to power an Arduino, the safe voltage range for each input, and how to add a soft power switch with a button and a P-channel MOSFET.

On this page
  1. Ways to power an Arduino
  2. Power over USB
  3. Power through the barrel jack or VIN
  4. Power through the 5V pin
  5. Is Arduino 3.3 V or 5 V?
  6. Power sources that work
  7. Share a common ground
  8. Add a soft power switch
  9. Troubleshooting

You can power an Arduino Uno from USB, through its barrel jack, through its VIN pin, or through its 5V pin. Each input reaches the board in a different way, so the voltage you can safely use depends on which one you choose. For the barrel jack and VIN, the board’s documentation recommends 7 to 12 V. This guide covers each input, supplies that work well, and how to add a soft power switch so a button can turn the project on and off.

Ways to power an Arduino

Input Voltage Best for Watch out for
USB 5 V, regulated Programming, testing, small low-power projects A standard USB 2.0 port is rated for about 500 mA. Some power banks switch off when the draw is very small.
DC barrel jack 7 to 12 V recommended Wall adapters and battery packs Use a center-positive plug. Higher voltage makes the regulator run hotter.
VIN pin 7 to 12 V recommended Hard-wired supplies, or boards without a barrel jack Wiring to VIN skips the barrel jack, so check polarity first.
5V pin Regulated 5 V only Projects with their own regulated 5 V supply Bypasses the onboard regulator. Anything above 5 V can damage the board.

Power over USB

USB is the simplest option. It supplies regulated 5 V, and the board sends that power to its 5V rail without passing it through the barrel-jack regulator. A computer’s USB port is enough for uploading code and running small sketches. A USB wall charger or a power bank can run a finished project.

Keep two limits in mind. A standard USB 2.0 port is rated for about 500 mA, so a project with several motors or many LEDs may need a different supply. Some power banks also switch off when the current draw is very small, which can look like the Arduino has crashed. If that happens, try a different power bank or use a wall adapter.

Power through the barrel jack or VIN

For the barrel jack, use a DC adapter with a center-positive plug. The Uno’s jack takes a 2.1 mm inner-diameter plug. Choose an output between 7 and 12 V. The board’s regulator steps that voltage down to 5 V, and the extra voltage turns into heat. A 12 V supply therefore makes the regulator run hotter than a 9 V supply does, and the board wastes more battery energy. Voltages up to the 20 V limit are allowed, but they aren’t recommended.

VIN feeds the same regulator input, so the same range applies. Connect the supply’s positive wire to VIN and its negative wire to any GND pin. Because VIN skips the barrel jack, check the polarity with a multimeter before you connect the supply to a board that’s already plugged in.

Power through the 5V pin

The 5V pin normally carries the 5 V that the board’s regulator or USB supplies. You can also feed 5 V in from outside, but that skips the regulator. Use this input only with a regulated 5 V supply, and connect that supply’s ground to a GND pin. Don’t connect an unregulated battery, a 9 V battery, or any voltage above 5 V here. Doing so can damage the board and anything else on the 5 V rail.

Is Arduino 3.3 V or 5 V?

The classic Arduino Uno uses 5 V logic, so its digital pins output about 5 V. Some boards use 3.3 V logic instead, including the Arduino Due and the Nano 33 series. Check the datasheet for your board before you connect sensors, power, or other modules. Applying 5 V to a 3.3 V board can damage its pins.

Power sources that work

  • Wall adapter: A regulated DC adapter rated for 7 to 12 V, with more current capacity than your project draws, is the most practical choice for a project that stays in one place.
  • Battery pack: Six alkaline AA cells in a holder give about 9 V when new. Rechargeable NiMH cells start lower, so check that the pack stays above 7 V under your load.
  • 9 V battery: It falls within the barrel-jack range, but a 9 V battery holds little charge, so the board runs for only a short time.
  • Bench supply: Set it to 7 to 12 V, with a current limit a bit above your expected draw. The current readout helps you spot wiring faults.

Share a common ground

If you power motors, servos, or LED strips from a separate supply, connect that supply’s ground to an Arduino GND pin. The Arduino’s signal pins are referenced to its ground. Without a shared ground, the control signals have no common reference, and the parts may behave unpredictably. Keep high-current loads on their own supply and use the Arduino for control signals.

Add a soft power switch

A soft power switch lets a push button turn the project on, and lets the project shut itself down cleanly when you press the button again. A plain switch is the simplest option. A latching design uses a small circuit so the board can keep its own power on.

Option 1: a plain switch on the input

A slide or toggle switch on the supply’s positive wire is the simplest choice. It cuts power to the board completely and needs no code. Place it on the input supply, before the barrel jack or VIN. A switch on the barrel-jack supply doesn’t cut power from USB, so if you power the board from both, switch both.

Option 2: latching soft power with a P-channel MOSFET

A momentary push button can’t keep power on by itself. The usual fix is a latch: a P-channel MOSFET acts as the power switch, and the board holds it on.

The basic sequence works like this:

  1. The MOSFET’s gate is pulled up to the input voltage through a resistor, so the MOSFET is off when nothing is pressed.
  2. Pressing the button pulls the gate to ground. That turns the MOSFET on, and the board powers up.
  3. Early in the sketch, a spare digital pin drives the gate low through a transistor. This keeps the MOSFET on after you release the button.
  4. To turn off, the sketch releases that pin. The pull-up turns the MOSFET off, and the power drops.

The same button can also be read as an ordinary input. The sketch can check it while the project runs, for example to start a shutdown routine that saves data before it releases the latch.

Parts and wiring gotchas

  • Gate voltage rating. Check the gate-source voltage rating (Vgs) on the MOSFET’s datasheet. With a 9 V input and the gate pulled low, the gate sits about 9 V from the source. A part rated only for ±8 V is over its limit at that voltage and can fail. Choose a part rated well above your input voltage.
  • Pull-up resistor. A resistor from the gate to the input, somewhere around 10 kΩ to 100 kΩ, keeps the MOSFET off while the button is up.
  • Startup timing. Many pins are inputs when the board starts, so the latch pin may not hold the gate in the right state until your sketch runs. If you release the button too early, the power can drop out. Set the latch pin as the first line of setup(), and keep the button pressed until the board has started.
  • Voltage drop. With the board running, measure the voltage across the MOSFET, from source to drain. A large drop means the part’s on-resistance is too high for your current, and the board sees less voltage than you expect.
  • Part quality. Small MOSFETs from unknown sellers can be clones with weaker ratings than their markings suggest. Buy from a known distributor.
  • Position. Put the MOSFET on the input supply, before the barrel jack or VIN, not on the 5V pin.

Troubleshooting

  • The board resets when a motor or relay starts. The supply may be too weak, or the grounds aren’t shared. Check the supply’s current rating, and connect the grounds together.
  • The board won’t power on from the barrel jack. Measure the voltage between VIN and GND under load. It should be within 7 to 12 V. Check the plug’s polarity and the adapter’s rating.
  • A USB power bank shuts off. Some power banks turn off at low current. Try a different power bank, or use a wall adapter.
  • A battery runs down faster than expected. The board’s own draw and the regulator’s losses both add up.

To plan a battery or supply for your project, measure the board’s draw first. The current draw guide for the Arduino Uno explains how.

Keep exploring

Guides from other topics

All topics →