Interactive Mission

Blink an LED with ESP32

Your first real ESP32 project — one LED, a few wires, and code you write yourself. Let's make it blink!

Mission 01Beginner10–15 minutesParent SafeTeacher Friendly
Mission 01

Make Your First Light Blink!

The Story

You're the captain of a tiny spaceship — the ESP32.

Right now every light on your ship is off. Mission Control is waiting for a sign you're online.

Your first command? Turn on one small LED. When it blinks, you'll know your ship heard you — and you're officially a maker.

Explain Like I'm 12

  • An LED is a tiny light on a chip.
  • Your ESP32 is the brain — it has pins you connect wires to.
  • Power on → LED glows. Power off → LED goes dark.
  • Blink on, blink off — that's your first program!

What You'll Build

  • A breadboard circuit with one LED and your ESP32
  • A short program that blinks the light every half second
  • Proof that you can build hardware and write code

Things You'll Need

  • ESP32 DevKit boardAny board with a USB port
  • LEDAny color — 5 mm works great
  • 220 Ω resistorRed-red-brown stripes on the body
  • BreadboardHalf-size is perfect
  • Jumper wiresMale-to-male, at least 3
  • USB cableMust carry data — not charge-only

Component Spotlight

Meet the brain of your circuit — tap to learn more about your board.

How Does Blinking Work?

Concept Illustration ESP32 pin sends power through a resistor to the LED long leg, short leg returns to ground
  • Each pin on the ESP32 can be ON or OFF — these are called GPIO pins.
  • The resistor protects the LED from too much power — like a speed bump for electricity.
  • setup() runs once and tells the pin to be an output.
  • loop() repeats forever — turn on, wait, turn off, wait. That's the blink!

Wiring Diagram

Follow these steps in order. Unplug USB before you change any wires.

Wiring Diagram Breadboard wiring diagram — ESP32 GPIO 2 through a 220 ohm resistor to the LED long leg, LED short leg to GND
  1. 1

    Unplug USB. Place the ESP32 on the left and the breadboard on the right.

  2. 2

    Push the LED into the breadboard — long leg (+) in one row, short leg (−) in a different row.

  3. 3

    Connect GPIO 2 on the ESP32 to one end of the 220 Ω resistor (yellow wire).

  4. 4

    Connect the other end of the resistor to the same row as the LED's long leg (+).

  5. 5

    Connect the LED's short leg (−) row to GND on the ESP32 (black wire).

  6. 6

    Double-check — GPIO 2 → resistor → long leg → LED → short leg → GND.

  7. 7

    Plug in USB and upload the code. Watch your LED blink!

Code

Copy this into Arduino IDE, then click Upload.

blink_led.ino
#define LED_PIN 2

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

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(500);
  digitalWrite(LED_PIN, LOW);
  delay(500);
}
  • setup() runs once — it tells the ESP32 that pin 2 is an output.
  • loop() runs forever — turn the LED on, wait half a second, turn off, wait again.
  • Try changing 500 to 200 for fast blinks or 1000 for slow ones.

Expected Output

  • The LED turns on for half a second, then off for half a second — over and over.
  • Many DevKit boards also blink a tiny onboard LED near the USB port — that's normal!

If nothing happens, check that your wire goes to GPIO 2 and the long LED leg connects to the resistor.

Mini Quiz

Quick check — no grades, just confidence!

Q1. Why do we use a resistor with the LED?

Q2. Which line of code turns the LED on?

Q3. Which pin is the LED connected to in this mission?

Challenge Yourself

No wrong answers — experiment and have fun!

  • Blink faster — change delay(500) to delay(200).
  • Blink slower — try delay(1000) for a calm, slow pulse.
  • Blink SOS — three short, three long, three short.
  • Invent your own pattern — can you make a heartbeat or a disco flash?

Mission Complete!

You just became an ESP32 maker.

You built a real circuit, wrote real code, and made a light blink on command. Every inventor, engineer, and robot builder started exactly here.

  • Connected an LED safely with a resistor
  • Used GPIO 2 as a digital output
  • Uploaded and ran your first Arduino program

Continue Your Journey