Sub topic 13
How Much Current a Pin and the Board Can Supply
Assume you know basic voltage, current, and resistance, and that you can upload an Arduino sketch and read a simple breadboard circuit. This chapter uses the Arduino Uno R3 as the reference board.
The working model
An Uno pin is a signal connection, not a general-purpose power supply. A pin can be configured as an input or an output. As an output, it can source current by driving HIGH, or sink current by driving LOW.
For an Uno, use 20 mA per I/O pin as a practical maximum. The ATmega328P datasheet lists 40 mA as an absolute maximum, but that is a damage limit, not a useful operating target. Staying near or below 20 mA also reduces voltage drop and heat.
The microcontroller has a total current limit as well. Current from several pins adds together. A design with eight pins each drawing 20 mA can stress the chip even though no individual pin exceeds 20 mA. The Uno board also has limits on its 5V regulator, USB supply, and external power input.
| Load | Typical connection | Safe approach |
|---|---|---|
| Small LED | Digital pin | Use a series resistor |
| Button | Digital input | Use `INPUT_PULLUP` or an external resistor |
| Motor or relay | External power | Use a transistor or motor driver |
| LED strip | External power | Use a suitable power supply and switching circuit |
Use a resistor with an LED
An LED needs a resistor to limit current. Without one, the LED and the output pin may draw excessive current.
For a 5V Uno, a red LED with a forward voltage of about 2V and a target current of 10 mA needs approximately:
R = (5V - 2V) / 0.010A = 300 ohms
A standard 330-ohm resistor is a suitable choice. Connect the resistor in series with the LED. The resistor can be between the pin and the LED, or between the LED and GND.
const int ledPin = 8;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}Loads that need a driver
Motors, solenoids, relays, speakers, and long LED strips usually need more current than an Uno pin should provide. They can also create voltage spikes when switched off.
Use a transistor or a motor-driver module. Power the load from a supply sized for it, connect the supply ground to the Uno ground, and place a flyback diode across a motor or relay coil when the switching circuit requires one. The Arduino pin then controls the driver rather than carrying the load current.
Common errors
- Treating the 5V pin as if it can always supply 500 mA. Its available current depends on whether power comes from USB, the barrel jack, or VIN, and on regulator heat.
- Forgetting that current flows through the complete circuit. A load connected to a pin must also have a suitable return path.
- Exceeding the total current of several pins.
- Connecting two outputs together. If one drives
HIGHand the other drivesLOW, the resulting current can be destructive. - Assuming every Arduino board has the Uno's limits. Check the board's documentation before copying a circuit.
Exercise
You want to control a 12V, 1A motor from an Uno. Should the motor connect directly to pin 9? What should you use instead?
Show answer
No. Use a separate 12V supply and a suitable transistor or motor-driver circuit. Connect the grounds, and add a flyback diode if the circuit uses a coil or motor.