ESP32-S3 traffic light
Three LEDs, red, green and yellow, that light up in turn like an Italian traffic light. A good first project: ten lines of program, three LEDs with their resistors, no soldering. Try it in the simulator before you buy anything.
The program
Chip BASIC: every line is one instruction you can read and change. The compiler checks it at every release of the site.
10 LED red, on
20 WAIT 5s
30 LED red, off
40 LED green, on
50 WAIT 5s
60 LED green, off
70 LED yellow, on
80 WAIT 1s
90 LED yellow, off
100 GOTO 10What you should see: red on for 5 seconds, then green for 5 seconds, then yellow for 1 second, and the cycle starts again. Always one light at a time.
▶ Open it in the IDEIn the simulator you see the logic run right away, with no hardware. The simulator does not check the wires: you check those on the board, and the IDE's wiring check walks you through it.
The parts
The compiler finds the parts in the program. Each has its own page with a test program to run before you build the whole thing.
- 3 × LED (with 220 ohm resistor)The part's page: LEDs: red, yellow and green lights
How to wire it to an ESP32-S3
- + red → ESP32-S3: GPIO4Through a 220Ω resistor
- + yellow → ESP32-S3: GPIO2Through a 220Ω resistor
- + green → ESP32-S3: GPIO1Through a 220Ω resistor
- − → ESP32-S3: GNDCommon ground: this link is mandatory.
If it does not work
- The lights: the program runs but nothing happens
- The LED is the wrong way round, or the series resistor is missing. The long leg goes on the board pin's side, the short one towards GND, with the 220 Ω resistor in between.
What you can change
The times are the WAIT lines: line 20 is how long it stays red, 50 the green, 80 the yellow. In the IDE you can ask Chip to add a pedestrian button or a buzzer.
Which boards it works on
- ESP32-S3 Freenove: yes
- Nordic nRF54LM20 DK: yes
- Arduino UNO R4 WiFi: yes