Learn Arduino

Lesson 2 of 16 · 15 min

Blink an LED on Arduino: The Complete First Circuit

To blink an LED on an Arduino, connect the long leg (anode) through a 220 Ω resistor to pin 13 and the short leg to GND, then switch the pin HIGH and LOW with digitalWrite() and pause between the two with delay().

This lesson also runs on an interactive 3D board: wire it, press Run and watch the circuit respond.

Open the 3D lesson

Blinking an LED is the “hello world” of electronics, and it teaches the three ideas every later lesson builds on: a pin can be an output, current needs a path back to ground, and a resistor protects the parts on that path.

The LED drops about 2 V and wants roughly 15 mA. With a 5 V pin, a 220 Ω resistor leaves (5 − 2) ÷ 220 ≈ 14 mA — bright and safe. Any resistor from 220 Ω to 1 kΩ works; bigger values simply dim the LED.

What you need

Everything below is in a standard Arduino starter kit.
PartQtyNotes
Arduino Uno R31Pin 13 already has a built-in LED, so you can test without any parts
5 mm red LED1Long leg = anode (+), short leg = cathode (−)
220 Ω resistor1Red-red-brown; 330 Ω or 1 kΩ also work
Breadboard + 2 jumpers1Or use the on-board LED on pin 13

How to wire it

Pin 13 → 220 Ω resistor → LED long leg. LED short leg → GND. The resistor can sit on either side of the LED; what matters is that it is in series, never in parallel.

Pin-by-pin wiring for this lesson.
PinConnects toWhat it does
D13Resistor → LED (+)The sketch switches this pin HIGH and LOW.
GNDLED (−)The short leg returns current to the board.
Wiring map for Blink an LED on Arduino: D13 to Resistor → LED (+), GND to LED (−).
Every connection this lesson needs, drawn from the pin table above.

How to blink an LED on an Arduino

Three things have to be true before the LED lights: the pin must be an output, the LED must face the right way, and something must limit the current. pinMode(13, OUTPUT) handles the first. The long leg is the anode and goes towards the pin; the short leg goes to ground through the resistor. Leave the resistor out and the LED draws whatever the pin can give until it burns out.

The resistor value comes from the LED's forward voltage. A red LED drops about 2 V, so (5 − 2) ÷ 0.015 A ≈ 200 Ω, which is why 220 Ω is the standard answer. Blue, white and green LEDs drop 3.0–3.4 V and want nearer 120 Ω. Anything from 220 Ω to 1 kΩ is safe for a 5 mm indicator LED; the larger values only make it dimmer.

Fading an LED instead of blinking it

digitalWrite() gives you two states. analogWrite() gives you 256, on the six PWM pins 3, 5, 6, 9, 10 and 11. The pin switches on and off about 490 times a second at a duty cycle you set, and the LED averages that flicker into a brightness your eye reads as continuous.

A straight ramp from 0 to 255 looks wrong: most of the visible change happens in the bottom third and the top end looks flat. Squaring the value — brightness × brightness ÷ 255 — spreads the steps where your eye can see them, which is the difference between a fade that looks mechanical and one that breathes.

One detail about pin 13: it already drives the “L” LED through a buffer on the board, so an external LED there lights alongside the built-in one and shares the pin's drive. Use pin 8 or 9 when you want only your own LED in view. Any digital pin can blink; only the six PWM pins can fade.

The sketch

blink.ino
const int LED_PIN = 13;  // the pin the LED is wired to

void setup() {
  pinMode(LED_PIN, OUTPUT);  // this pin will drive current
}

void loop() {
  digitalWrite(LED_PIN, HIGH);  // LED on
  delay(500);                   // half a second
  digitalWrite(LED_PIN, LOW);   // LED off
  delay(500);                   // half a second
}

What the code does

  1. const int LED_PIN = 13 gives the pin a name, so you only change it in one place.
  2. setup() runs once: pinMode(LED_PIN, OUTPUT) makes the pin a driver instead of an input.
  3. loop() runs forever: HIGH, wait, LOW, wait. Those two delays set the rhythm of the blink.
  4. Change both delays to 100 for a fast strobe, or 2000 for a slow pulse.

Specifications

Typical values for the parts used here.
ItemValue
LED5 mm, 1.8–3.2 V forward
Max current20 mA
Resistor220 Ω (red-red-brown)
LED current≈ (5 − 2) ÷ 220 ≈ 14 mA
Pin 13 limit40 mA absolute max

Common mistakes

Sources

The figures in this lesson come from these documents. Every value in the tables above can be checked against them.

Frequently asked questions

Which resistor should I use with an LED on 5 V?

220 Ω for a standard 5 mm LED: about 14 mA, bright and well inside the 20 mA rating. For a 3.3 V board use 100 Ω. For a dim indicator LED, 1 kΩ gives about 3 mA.

Why does my LED stay on instead of blinking?

Almost always a missing delay() or a delay so short you cannot see it. Check that both digitalWrite() calls and both delay() calls are inside loop().

Do I need a resistor if I use pin 13?

The board has a resistor in series with its own “L” LED, so the built-in one is safe. An external LED still needs its own 220 Ω resistor.

Can I blink two LEDs at once?

Yes. Give each LED its own pin and resistor, then write both pins inside the same loop. Pins 3, 5, 6, 9, 10 and 11 can also fade with analogWrite().

Want to see this circuit before you own the parts? The Arduino simulator draws this exact pin table on a 3D Uno R3: click any jumper to see what it carries, press Run and read the serial monitor.

Open the Arduino simulator

Published 12 November 2026 · last updated 19 November 2026 · written and tested by Nick Hu.