LED Blink Interface & Program

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

ComponentQuantity
ESP32 Board1
LED1
220Ω Resistor1
Breadboard1
Jumper Wires2

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 PinConnected To
GPIO 2LED Positive Terminal
GNDLED Negative via 220Ω Resistor

ESP32 LED Connection

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

CodePurpose
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.
Scroll to Top