How to wire an LED to an Arduino Nano
To wire an LED to an Arduino Nano, connect A to pin 2 and C to GND. The Arduino Nano’s pin is 5 V and a 220 ohm resistor in series limits the current through the LED to about 14 mA, so nothing else is needed. The sketch below uses no library beyond what the board includes. It blinks the LED, half a second on and half a second off, printing LED on and LED off.
- 5 V logic
- Library: none
- 2 wires, 1 helper parts
LED to Arduino Nano wiring table
Every wire in the circuit above, with the part’s pin names and the board’s own labels. The wire colors are the ones the circuit uses; on a real bench any colors work.
| LED pin | Arduino Nano pin | Wire color | Why |
|---|---|---|---|
| A (anode) | pin 2, through R1 (220 Ω) | amber | The long leg. Current flows in here, so it takes the signal, with the resistor in the way. |
| C (cathode) | GND | blue | The short leg, on the flat side of the lens, goes to ground. |
| 220 ohm resistor | In series with the anode | n/a | Limits the current. Without it the LED, the pin or both burn out. |
Helper parts
The extra parts in the circuit above, and where their wires go:
| From | To | Wire color |
|---|---|---|
| R1 (220 Ω) pin 1 | 2 | green |
Power and logic levels for LED and Arduino Nano
Logic level
The Arduino Nano’s pins are 5 V logic. A 5 V part can drive them directly; a part whose signal pins are limited to 3.3 V needs a level shifter.
This pair
A red LED drops about 2 V, so with 220 ohm in series a 5 V pin pushes about 14 mA through it: bright enough to see and gentle on the pin. The resistor can sit on either side of the LED; what matters is that it is in the loop.
Pins to leave alone
A6 and A7 are analog only: pinMode(A6, OUTPUT) does nothing and digitalRead(A7) is not there to call. D0 and D1 are the USB serial port.
The working code for the Arduino Nano
Library: none, the sketch drives the pin with digitalWrite(). This is the sketch the circuit above runs.
const int LED_PIN = 2; // pin 2, through a 220 ohm resistor to the LED
void setup() {
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
Serial.println("LED on");
delay(500);
digitalWrite(LED_PIN, LOW);
Serial.println("LED off");
delay(500);
}
What you should see
The LED lights for half a second and goes dark for half a second. The serial monitor, at 9600 baud, prints LED on and LED off as the pin changes.
An LED that never lights is usually in backwards: the long leg, the anode, faces the resistor and the pin.
The serial monitor prints this, recorded from the circuit above running for two and a half seconds:
LED on
LED off
LED on
LED off
LED onCommon mistakes wiring an LED to an Arduino Nano
Putting the LED in backwards
An LED passes current one way only. Backwards it stays dark and nothing is damaged. If it never lights, swap its two legs: the long leg, the anode, faces the signal.
Leaving out the resistor
An LED has almost no resistance once it conducts, so the only limit on the current is the pin. At 5 V that is far more than the LED’s 20 mA rating. The simulator burns the LED out and shows it dark for good, as a real one goes.
Picking A6 or A7
A6 and A7 look like the other analog pins but are inputs to the ADC and nothing else. the LED on either of them never sees a digital level. Any of D2 to D13 or A0 to A5 works.
Build your own LED project
Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.