The Circuit Maker
Projects8 min read

Arduino LED Blink: The Classic First Arduino Project

Make an LED blink with Arduino. Complete tutorial with wiring diagram, code, and line-by-line explanation. The standard first project for learning Arduino programming.

·

The LED blink sketch is the classic first Arduino project — it turns an LED on and off repeatedly using just three lines of code. It's the "Hello World" of hardware programming and introduces the core concepts: digital output, timing, and the Arduino program structure. Every Arduino has a built-in LED on pin 13, so you can run this project with zero external components.

What you need

ComponentNotes
Arduino Uno (or Nano, Mega)Any Arduino board works
USB cableType-A to Type-B for Uno; micro-USB for Nano
Arduino IDEFree from arduino.cc (or use the web editor)

For the external LED version, you'll also need a standard 5mm LED, a 220Ω–330Ω resistor, a breadboard, and jumper wires.

The blink sketch

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

void loop() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}

Line-by-line explanation

setup()

The setup() function runs once when the Arduino powers on or resets. Here, we use pinMode(13, OUTPUT) to configure digital pin 13 as an output. This tells the Arduino we want to send voltage out of this pin rather than read from it.

loop()

The loop() function runs continuously, repeating forever after setup() finishes. Each cycle:

  1. digitalWrite(13, HIGH) — Sets pin 13 to 5V, turning the LED on.
  2. delay(1000) — Pauses for 1000 milliseconds (1 second).
  3. digitalWrite(13, LOW) — Sets pin 13 to 0V, turning the LED off.
  4. delay(1000) — Pauses for another second before the loop repeats.

The result: the LED blinks on and off, one second at a time, forever (or until you unplug the Arduino).

How to upload the sketch

  1. Connect the Arduino to your computer with the USB cable.
  2. Open the Arduino IDE.
  3. Go to Tools → Board and select your board (e.g., "Arduino Uno").
  4. Go to Tools → Port and select the COM port that appeared when you plugged in the Arduino.
  5. Paste the blink code into the editor (or go to File → Examples → 01.Basics → Blink).
  6. Click the Upload button (→ arrow icon).
  7. Wait for "Done uploading" to appear at the bottom. The built-in LED should start blinking.

Adding an external LED

The built-in LED is useful for testing, but connecting your own LED teaches wiring and demonstrates why you need a current-limiting resistor.

Wiring

  1. Place the LED on the breadboard.
  2. Connect a 220Ω resistor from Arduino pin 13 to the LED's longer leg (anode).
  3. Connect the LED's shorter leg (cathode) to the breadboard's ground rail.
  4. Connect the breadboard ground rail to an Arduino GND pin with a jumper wire.

The same blink sketch works without changes — pin 13 drives both the built-in LED and your external LED simultaneously. To use a different pin (e.g., pin 8), just change all instances of 13 to 8 in the code.

Why the 220Ω resistor?

Arduino output pins provide 5V. A red LED has a forward voltage of about 2V and a safe operating current of 20 mA. Using our LED resistor calculator:

R = (5V - 2V) / 0.02A = 150Ω (minimum)

220Ω provides a comfortable safety margin (~14 mA), and it's a very common resistor value. 330Ω works fine too (about 9 mA — slightly dimmer but perfectly visible). Learn to identify resistor values with our color code guide.

Variations to try

Change the blink speed

// Fast blink (5 times per second)
delay(100);

// Slow blink (once every 3 seconds)
delay(1500);  // on for 1.5 sec, off for 1.5 sec

// Heartbeat pattern
digitalWrite(13, HIGH); delay(100);
digitalWrite(13, LOW);  delay(100);
digitalWrite(13, HIGH); delay(100);
digitalWrite(13, LOW);  delay(700);

Blink multiple LEDs

int ledA = 8;
int ledB = 9;

void setup() {
  pinMode(ledA, OUTPUT);
  pinMode(ledB, OUTPUT);
}

void loop() {
  digitalWrite(ledA, HIGH);
  digitalWrite(ledB, LOW);
  delay(500);
  digitalWrite(ledA, LOW);
  digitalWrite(ledB, HIGH);
  delay(500);
}

This alternates two LEDs, each on its own pin with its own resistor. For detailed wiring of multiple LEDs, see our Arduino LED wiring guide.

Use a variable for the pin

const int LED_PIN = 13;
const int BLINK_INTERVAL = 500;

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

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

Using named constants (const int) instead of raw numbers makes code easier to read and modify. This is good practice for all Arduino projects.

Key concepts this project teaches

ConceptWhat you learned
Digital outputPins can be set HIGH (5V) or LOW (0V)
setup() and loop()Every Arduino sketch has these two functions
Timingdelay() pauses execution for a set time
Current limitingLEDs need a series resistor to prevent burnout
PolarityLEDs are directional — long leg to positive

Troubleshooting

ProblemSolution
Upload fails: "port not found"Check USB cable (must be data cable, not charge-only). Try a different USB port. Install drivers if needed.
Upload fails: "board not recognized"Go to Tools → Board and select the correct board. Arduino Nano clones often need "Old Bootloader" option.
Built-in LED blinks but external doesn'tCheck wiring: resistor → LED anode (long leg) → LED cathode → GND. Try reversing the LED.
LED stays on, doesn't blinkMake sure both delay() calls are present. Check that the code uploaded successfully.
LED is very dimResistor value may be too high. Verify with calculator.

Next steps

After blinking an LED, try these projects to build on what you've learned:

Summary

The Arduino blink sketch uses pinMode() to configure pin 13 as output, then toggles it between HIGH (5V, LED on) and LOW (0V, LED off) with delay() in between. It works with the built-in LED immediately, or with an external LED through a 220Ω resistor. This project introduces digital output, the setup/loop structure, timing, and current limiting — the foundation for every Arduino project that follows.