Beginner 45 mins ESP32 GPIO LED Beginner

Blinking LED with ESP32

Control a GPIO pin to blink an LED — the "Hello World" of embedded systems and the foundation of every IoT project.

Understanding the Concept

The Blinking LED project is the fundamental starting point for any embedded systems journey. In this module, you will learn how a microcontroller like the ESP32 can control external hardware using its General Purpose Input/Output (GPIO) pins.

By the end of this module, you will understand how digital output signals work, how to write your first Arduino sketch, and how to physically connect an LED to a breadboard circuit.

What is GPIO?

GPIO stands for General Purpose Input/Output. These are programmable digital pins on the ESP32 that can be configured as either inputs (reading sensor data) or outputs (controlling devices like LEDs, motors, and relays).

In this project, we configure GPIO 2 as a digital output and toggle it between HIGH (3.3V) and LOW (0V) with a 1-second delay — causing the LED to blink on and off in a repeating cycle.

Why Start with an LED?

Blinking an LED teaches you the three fundamental concepts used in every IoT project:

  • Pin configuration — telling the microcontroller how to use a pin
  • Digital write — sending voltage to control external components
  • Timing — controlling how long actions last using delays

Once you understand these concepts, you can control motors, relays, speakers, displays, and any other output device.

How It Works — Step by Step

Watch the execution flow animate step-by-step inside the ESP32.

Interactive 3D Hardware

Rotate: drag · Zoom: scroll · Click any component for details.

Loading 3D scene…
Click a component
Select any part of the circuit to see its description.

What You'll Need

ESP32 Development Board
Qty: 1
Dual-core Xtensa LX6 processor running at 240 MHz. Built-in WiFi 802.11 b/g/n, Bluetooth 4.2, and 30+ GPIO pins operating at 3.3V logic.
LED (Red)
Qty: 1
Light Emitting Diode. Forward voltage: ~2.0V. Maximum forward current: 20mA. The longer leg is the Anode (+), shorter leg is the Cathode (−).
220Ω Resistor
Qty: 1
Current-limiting resistor (Red-Red-Brown color bands). Prevents excess current from burning the LED. Calculates to ~6mA at 3.3V.
Breadboard (830 tie)
Qty: 1
Solderless prototyping board. Horizontal rails at top and bottom (+/−) are power rails. Vertical columns in the center are connected in groups of 5.
Jumper Wires
Qty: 3
Short flexible wires for making connections on the breadboard. Use red for positive (3.3V/GPIO) and black for ground connections.
USB Cable (Type-C/Micro)
Qty: 1
Connects ESP32 to your computer for programming and as the power source. Ensure you use a data-capable cable, not a charge-only cable.

Hardware Connections

# Component / Pin Connects To Wire Notes
1 ESP32 GPIO 2 220Ω Resistor (Leg 1) Use a red jumper wire
2 220Ω Resistor (Leg 2) LED Anode (+) Connect directly on breadboard
3 LED Cathode (−) ESP32 GND Use a black jumper wire for GND
4 ESP32 3V3 (optional) Breadboard + Rail Only if using breadboard power rail
5 ESP32 GND (optional) Breadboard − Rail Connect GND rail for cleaner wiring

Arduino / ESP32 Code

Blinking LED — Complete Arduino Sketch
CPP
// ══════════════════════════════════════════════
// Mindrevel IoT Workshop — Session 1
// Project  : Blinking LED with ESP32
// Board    : ESP32 Dev Module
// GPIO Pin : 2 (Built-in blue LED on most boards)
// Author   : Mindrevel IoT Team
// ══════════════════════════════════════════════

const int LED_PIN    = 2;     // GPIO pin number
const int BLINK_RATE = 1000;  // Blink interval in ms

// ── setup() ── Runs ONCE on power-on ──────────
void setup() {
  Serial.begin(115200);           // Start serial monitor
  pinMode(LED_PIN, OUTPUT);       // Set GPIO 2 as output
  Serial.println("Mindrevel IoT — Blinking LED Ready!");
}

// ── loop() ── Runs CONTINUOUSLY ───────────────
void loop() {
  // Turn LED ON
  digitalWrite(LED_PIN, HIGH);
  Serial.println("[ON]  LED is ON  — GPIO 2 = 3.3V");
  delay(BLINK_RATE);

  // Turn LED OFF
  digitalWrite(LED_PIN, LOW);
  Serial.println("[OFF] LED is OFF — GPIO 2 = 0V");
  delay(BLINK_RATE);
}

Resources & Downloads

Arduino IDE Setup Guide
Step-by-step guide to install and configure Arduino IDE 2.x for ESP32 development.
PDF 1.8 MB Global
ESP32 Pinout Reference Card
Complete GPIO pinout diagram for the ESP32 DevKit V1 development board. Essential reference for all projects.
PDF 890 KB Global
Workshop PDF — Blinking LED
Complete lecture notes with theory, circuit diagrams, and step-by-step instructions for the blinking LED project.
PDF 2.4 MB
Presentation Slides (PPT)
Workshop slides used during the Mindrevel IoT session 1 presentation.
PPT 5.1 MB
Arduino Sketch (.ino)
Ready-to-upload Arduino IDE sketch for the blinking LED project.
CODE 1.2 KB