EXPERIMENT – 2
Titlc:
Simulation of ESP32 LED Blinking Program Using Wokwi
Aim:
To study the basic functioning of the ESP32 microcontroller by simulating an LED
blinking program the Wokwi online simulator.
Tools / Compokckts Uscd:
Haídwaíc (Simmlatiok):
1. ESP32 Development Board
2. LED
3. Resistor (256 Ω)
Softwaíc:
1. Computer / Laptop
2. Internet connection
3. Wokwi
Online
Simulator
Tkcoíy:
The ESP32 is a low-cost, low-power, and high-performance microcontroller
developed by Espressif Systems. It is widely used in embedded systems and Internet
of Things (IoT) applications due to its dual-core processor, built-in Wi-Fi and
Bluetooth capabilities, and large number of General Purpose Input Output (GPIO)
pins. These GPIO pins can be configured either as input pins to read sensor data or as
output pins to control external devices such as LEDs, motors, and relays.
An LED (Light Emitting Diode) is a semiconductor device that emits light when it
is forward biased. It allows current to flow only in one direction, from anode to
cathode. If excessive current flows through the LED, it may get damaged. Hence, a
current-limiting resistor is connected in series with the LED to restrict the current
and protect the LED.
In this experiment, one GPIO pin of the ESP32 is configured as an output pin using
the pinMode() function. The LED is controlled by sending HIGH (3.3 V) and LOW
(0 V) signals to the GPIO pin using the digitalWrite() function. When the GPIO pin
is HIGH, current flows through the LED and it glows. When the pin is LOW,
current flow stops and the LED turns OFF.
A delay between ON and OFF states is introduced using the delay() function, which
pauses the execution of the program for a specified time in milliseconds. A delay of
1000 milliseconds (1 second) is used so that the blinking of the LED is clearly visible.
24BIT193
The program runs continuously inside the loop() function, which executes repeatedly
as long as the ESP32 is powered. The setup() function executes only once at the
beginning to initialize the GPIO pin and serial communication. Serial communication
is enabled using [Link]() to display messages such as “LED ON” and “LED
OFF” on the serial monitor.
Wokwi is an online simulation platform that allows testing and verification of
microcontroller programs without physical hardware. It supports ESP32 and
Arduino boards and provides real-time visualization of circuit operation. This
experiment demonstrates basic GPIO control and forms the foundation for more
advanced embedded and IoT applications.
Block Diagíam
ESP32 GPIO Pin → LED → Resistor → Ground
Block Diagíam Enplakatiok
The ESP32 sends digital HIGH and LOW signals to a GPIO pin.
When the pin is HIGH, current flows through the LED and it turns ON.
When the pin is LOW, current stops flowing and the LED turns OFF.
The resistor limits the current through the LED and prevents damage.
Píoccdmíc
1. Open a web browser and go to the Wokwi online simulator website.
2. Create a new ESP32 project.
3. Place the ESP32 board, LED, and resistor in the simulation workspace.
4. Connect GPIO pin D4 of the ESP32 to the anode of the LED.
5. Connect the cathode of the LED to a 256 Ω resistor and then to the ground
pin of ESP32.
6. Write the LED blinking program with a delay of 1 second.
7. Verify the code and start the simulation.
8. Observe the LED blinking continuously with a time interval of 1 second.
9. Monitor the serial output showing “LED ON” and “LED OFF”.
Píogíam Codc
#define LED_PIN 4
void setup() {
pinMode(LED_PIN, OUTPUT);
[Link](115200);
[Link]("ESP32 Blinking LED Started!");
}
void loop() {
24BIT193
digitalWrite(LED_PIN, HIGH);
[Link]("LED ON");
delay(1000);
digitalWrite(LED_PIN, LOW);
[Link]("LED OFF");
delay(1000);
}
Obscívatioks
• The LED turns ON and OFF alternately.
• The blinking interval is 1 second.
• Serial monitor displays “LED ON” and “LED
OFF” repeatedly.
• The simulation runs continuously without errors.
Result
The ESP32 LED blinking program was successfully simulated using Wokwi. The
LED blinked continuously with a time delay of 1 second, and serial messages were
displayed correctly. Hence, the aim of the experiment was achieved.
Conclusion
The ESP32 microcontroller was successfully simulated and programmed to blink an
LED using a fixed time delay. This experiment helped in understanding the working of
GPIO pins, basic programming structure of ESP32, and the use of Wokwi for circuit
simulation. It serves as a foundation for advanced embedded systems and IoT-based
applications.
24BIT193