Sub topic 1
Why an Arduino Pin Cannot Power a Motor
Prerequisites
This chapter assumes you can upload sketches with the Arduino IDE, use setup() and loop(), call pinMode() and digitalWrite(), and identify voltage, current, and ground in a simple circuit. You should also be comfortable placing components on a breadboard.
The pin is a signal source, not a power supply
An Arduino I/O pin is a small electronic output. It can produce a logic HIGH or LOW signal and can supply a small amount of current to a device such as an LED through a resistor.
A motor is a load that converts electrical power into motion. Even a small motor can need much more current than an I/O pin can safely provide.
For an Arduino Uno, the ATmega328P datasheet lists 40 mA as the absolute maximum current for one I/O pin. This is not a normal operating target. A lower current, often about 20 mA or less, is a safer design limit. The microcontroller also has limits for the combined current through groups of pins.
| Load | Typical Arduino pin use |
|---|---|
| LED with a resistor | Usually suitable |
| Sensor signal input | Suitable |
| Driver input | Suitable |
| DC motor winding | Unsafe |
| Servo power lead | Unsafe |
Connecting a motor directly to a pin can overheat or permanently damage the microcontroller. The pin may also fail to produce a valid HIGH voltage because its output circuit cannot deliver the required current.
Why motors demand extra current
A motor usually draws its highest current when it starts or when its shaft is blocked. This is called stall current. At startup, the motor is not turning, so it produces almost no back electromotive force, or back-EMF. Back-EMF is a voltage created by a spinning motor that opposes the supply voltage and reduces current during normal operation.
The startup current can be several times the current measured while the motor is already spinning. A pin that appears to work briefly may still be overloaded every time the motor starts.
Motors also contain coils. A coil stores energy in a magnetic field. When current through the coil is interrupted, the stored energy produces a voltage spike called inductive kickback. That spike can travel back into the Arduino pin and damage other circuit parts.
Use a driver between the pin and motor
A driver is a circuit that lets a low-power control signal operate a higher-power load. The Arduino pin sends only a control signal. The driver receives power from a suitable external supply and switches the motor current.
For a simple DC motor, a logic-level N-channel MOSFET can act as a low-side switch. A flyback diode provides a safe path for the motor's inductive current when the MOSFET turns off. For a motor that must reverse direction, use an H-bridge driver board.
A hobby servo also needs separate power. Its signal wire connects to an Arduino pin, but its power and ground wires connect to a supply that can provide the servo's current. The Arduino ground and the external supply ground must be connected so the signal has a shared reference.
The Arduino can safely control a driver input:
const byte DRIVER_INPUT = 5;
void setup() {
pinMode(DRIVER_INPUT, OUTPUT);
}
void loop() {
digitalWrite(DRIVER_INPUT, HIGH); // The driver turns the motor on.
delay(1000);
digitalWrite(DRIVER_INPUT, LOW); // The driver turns the motor off.
delay(1000);
}This sketch does not power a motor from pin 5. It assumes that pin 5 is connected to the input of a motor driver. The driver and motor use their own power path.
Exercise
Why can an Arduino pin control a motor driver but not power a motor directly?
Show answer
The pin supplies a small control signal, while the driver draws motor current from a properly sized external supply and handles switching protection.