All parts

LEDs: red, yellow and green lights

Three coloured lights the program turns on and off: the first part of almost every project, from a traffic light to indicator lamps.

The test program

Test this part on its own before you build the rest: if it works alone, the rest is built on something you know works.

10 LED red, on
20 WAIT 500
30 LED red, off
40 LED yellow, on
50 WAIT 500
60 LED yellow, off
70 LED green, on
80 WAIT 500
90 LED green, off
100 GOTO 10

What you should see: The lights come on one at a time, red, yellow and green, and start again.

▶ Try it in the IDE

What to buy

  • 3 × LED (with 220 ohm resistor)

How to wire it to an ESP32-S3

  1. + red → ESP32-S3: GPIO4Through a 220Ω resistor
  2. + yellow → ESP32-S3: GPIO2Through a 220Ω resistor
  3. + green → ESP32-S3: GPIO1Through a 220Ω resistor
  4. − → ESP32-S3: GNDCommon ground: this link is mandatory.

If it does not work

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.

Which boards it works on

  • ESP32-S3 Freenove: yes
  • Nordic nRF54LM20 DK: yes
  • Arduino UNO R4 WiFi: yes