Introduction
LED Blink is the first and most basic program in embedded systems and IoT learning.
In this tutorial, we will connect an LED with ESP32 and make it blink using Arduino IDE.
Required Components
| Component | Quantity |
|---|---|
| ESP32 Board | 1 |
| LED | 1 |
| 220Ω Resistor | 1 |
| Breadboard | 1 |
| Jumper Wires | 2 |
LED Basics
LED stands for Light Emitting Diode.
- Long Leg → Positive Terminal (Anode)
- Short Leg → Negative Terminal (Cathode)
Always use a resistor with LED to prevent excess current flow.
ESP32 LED Connection
Connect the LED with ESP32 as shown below:
| ESP32 Pin | Connected To |
|---|---|
| GPIO 2 | LED Positive Terminal |
| GND | LED Negative via 220Ω Resistor |

Arduino IDE Setup
Step 1:
Connect ESP32 board to computer using USB cable.
Step 2:
Open Arduino IDE.
Step 3:
Select Board:
Tools > Board > ESP32 Dev Module
Step 4:
Select correct COM Port from:
Tools > Port
ESP32 LED Blink Program
Upload the following program to ESP32 board.
int ledPin = 2;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
Program Explanation
| Code | Purpose |
|---|---|
| pinMode(ledPin, OUTPUT) | Set LED pin as output |
| digitalWrite(HIGH) | Turn LED ON |
| digitalWrite(LOW) | Turn LED OFF |
| delay(1000) | Wait for 1 second |
Output
After uploading the code successfully:
- LED turns ON for 1 second
- LED turns OFF for 1 second
- The process repeats continuously
Important Notes
- GPIO 2 is commonly connected to built-in LED in many ESP32 boards.
- Always use resistor with external LED.
- Check COM Port if upload fails.
- Use good quality USB cable for programming.
