Bench NotesUno handbook

Lighting an External LED

Wire an LED with a resistor, get its polarity right, and blink it from a digital pin.

BeginnerLEDResistorBreadboard

Overview

An LED is a diode: it conducts in one direction only and needs its current limited by a resistor. Get both of those right and it will last for years.

You will need

  • Arduino Uno R3
  • 5 mm LED
  • 330 Ω resistor (orange-orange-brown)
  • Breadboard and two jumper wires

Wiring

Uno pinConnects toNotes
7330 Ω resistor, then LED anode (long leg)Pin HIGH = LED on (active-high).
GNDLED cathode (short leg, flat edge on the rim)
Wiring for Lighting an External LEDArduino Uno D7 to LED anode (long leg) through 330 Ω; Arduino Uno GND to LED cathode (short leg).Connections (each line is one wire)Arduino UnoLEDD7anode (long leg)330 ΩGNDcathode (short leg)
Original wiring diagram. Each line is one jumper wire; boxes on a line are series resistors.

Polarity

The anode (+) is the longer leg. The cathode (−) is the shorter leg, and the plastic rim is flattened on that side. Reversed, the LED simply stays dark; it is not damaged at 5 V.

Active-high and active-low

Wired as above, writing HIGH turns the LED on. You can also wire the anode to 5V and the cathode (through the resistor) to the pin; then LOW turns it on. Both are fine, but your code must match the wiring.

The sketch

external_led_blink.ino
const int LED_PIN = 7;

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(300);
  digitalWrite(LED_PIN, LOW);
  delay(700);
}

How the code works

Naming the pin with a const int means you change the wiring in one place. With a 330 Ω resistor and a red LED (about 2 V forward voltage) the current is (5 − 2) ÷ 330 ≈ 9 mA, comfortably bright and well within the pin's limit.

What you should observe

  • A short 0.3 s flash every second.
  • No light at all: check the LED's direction first, then that the resistor and LED share a strip.