This project demonstrates how to simulate a traffic light system using ESP32 in Wokwi. The system controls three LEDs (Red, Yellow, and Green) to operate like a real traffic light using programmed time delays
The ESP32 microcontroller combines strong processing capability with wireless connectivity features such as Wi-Fi and Bluetooth. Its efficiency and adaptability make it a popular choice for IoT and embedded development
The simulation successfully demonstrated a working traffic light system. The green LED stayed on for 5 seconds, followed by yellow for 2 seconds, and red for 5 seconds. The sequence repeated continuously.
After that, I opened Wokwi
After selecting the ESP32 board
After opening the ESP32, I started adding the required components like LEDs and resistors
next, adding the resistors
After that, I added the red LED
Then, I changed the resistor value to 220 ohms to control the current flowing to the LED
After all the components were ready
After that, I started connecting the components to the ESP32 pins correctly.
I connected the Green LED with the 220 Ω resistor to GPIO 23 of the ESP32
After that, I connected the other components, like the yellow and green LEDs with their 220 Ω resistors, to the ESP32 pins
I connected the red, yellow, and green LEDs to the ESP32 using 220 Ω resistors on GPIO pins 23, 22, and 21. After completing the wiring, I wrote the code to control the LEDs in the traffic light sequence and ran the simulation to verify that each LED turned on and off at the correct time
After that, I started writing the code to control the traffic light
After writing the code, I started the simulation to test if the traffic light worked correctly
After running the simulation, I observed the results and confirmed that the traffic light sequence worked correctly, with each LED lighting up for the set time
After, I recorded a video of the simulation showing the traffic light in action, demonstrating that the LEDs changed correctly according to the programmed sequence
The Wokwi project was programmed using the following code