ESP32 Laboratory Exercise 1: LED Blink Experiment

Objective

The objective of this laboratory exercise is to introduce students to the basic operation of the ESP32 development board. In this experiment, students will learn how to program the ESP32 and control a simple electronic component by blinking an LED.

This experiment helps students understand:

  • Basic microcontroller programming
  • Digital output control
  • Uploading programs to the ESP32
  • Building a simple electronic circuit

Introduction

The ESP32 is a powerful microcontroller widely used in embedded systems and Internet of Things (IoT) applications. Developed by Espressif Systems, it includes built-in WiFi, Bluetooth, and many programmable input/output pins.

Before building complex projects such as wireless sensors or smart devices, engineers must first learn how to control basic components like LEDs. The LED blink experiment is the first laboratory exercise commonly used in embedded systems courses because it demonstrates the fundamental workflow of programming a microcontroller.


Laboratory Equipment and Components

The following materials are required to complete the experiment.

ComponentQuantity
ESP32 DevKit V1 development board1
Breadboard1
LED (Light Emitting Diode)1
220Ω resistor1
Jumper wiresSeveral
USB cable1
Computer with Arduino IDE installed1

Theory

An LED emits light when electric current flows through it. However, LEDs require a current limiting resistor to prevent excessive current that could damage the component.

The ESP32 controls the LED using one of its GPIO (General Purpose Input/Output) pins. By switching the GPIO pin HIGH or LOW, the microcontroller can turn the LED ON or OFF.

  • HIGH (3.3V) → LED ON
  • LOW (0V) → LED OFF

By repeating this process in a loop, the LED will blink.


Circuit Diagram

The circuit used in this experiment is very simple.

Connection steps:

  1. Connect the long leg (anode) of the LED to the resistor.
  2. Connect the other end of the resistor to GPIO 2 of the ESP32.
  3. Connect the short leg (cathode) of the LED to GND.

Circuit flow:

GPIO2 → Resistor → LED → GND


Experimental Procedure

Follow these steps to complete the experiment.

Step 1: Assemble the Circuit

Using the breadboard and jumper wires, build the LED circuit as described in the circuit diagram.

Step 2: Connect the ESP32

Connect the ESP32 board to your computer using a USB cable.

Step 3: Open the Arduino IDE

Launch the Arduino IDE software on your computer.

Step 4: Select the ESP32 Board

Navigate to:

Tools → Board → ESP32 Arduino → ESP32 Dev Module

Step 5: Write the Program

Enter the following program in the Arduino IDE.

int ledPin = 2;

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

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

Step 6: Upload the Program

Click the Upload button to compile and upload the code to the ESP32 board.

If required, press the BOOT button during the upload process.


Expected Output

After the program is uploaded successfully:

  • The LED will turn ON for 1 second
  • The LED will turn OFF for 1 second
  • The cycle will repeat continuously

This blinking behavior confirms that the ESP32 is successfully controlling the output pin.


Discussion

This experiment demonstrates how a microcontroller can control electronic devices using digital signals. The program runs continuously in the loop() function, allowing the LED to blink repeatedly.

The delay function determines how long the LED remains ON or OFF. By changing the delay value, students can control the blinking speed.

For example:

  • delay(500) → faster blinking
  • delay(2000) → slower blinking

This experiment forms the foundation for many embedded systems applications such as:

  • status indicators
  • alarm systems
  • digital displays
  • sensor monitoring systems

Conclusion

In this laboratory exercise, students successfully learned how to control an LED using the ESP32 development board. The experiment demonstrated the basic workflow of building a circuit, writing a program, and uploading code to a microcontroller.

Understanding this process is essential for developing more advanced projects involving sensors, communication modules, and automation systems.


Guide Questions

  1. What is the purpose of the resistor in the LED circuit?
  2. What happens if the LED is connected without a resistor?
  3. What is the function of the setup() function in the program?
  4. What is the role of the loop() function?
  5. How can the blinking speed of the LED be changed?

Next Laboratory Exercise

In the next experiment, students will learn how to read digital input from a push button and control an LED using user input.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
8
0
Would love your thoughts, please comment.x
()
x
Update cookies preferences