Lights and displaysA Traffic Light with Three LEDs
Build a small model of a real traffic light: green, flashing green, yellow, red and finally red with yellow, just like on the street.
Lights and displaysEveryone starts here: the LED built into the board turns on and off once a second. You'll learn how to install the Arduino IDE, write code and upload it to the board.
Adapted from “Blink” by Arduino. Licence: CC BY-SA 4.0. This translation is shared under the same licence. The parts list and the tips are RoboHub's.
Choose a variation and the parts list updates.
Download Arduino IDE 2 from arduino.cc and install it. Connect the board to the computer with a USB cable.
In the list at the top, choose your board, for example Arduino Uno R4 WiFi, and the port it is connected to. For the R4 the IDE offers to install the board package: accept it.
Paste the code and press the arrow (Upload). A few seconds later the LED next to the “L” label on the board starts blinking.
// The LED on the board: one second on, one second off.
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // on
delay(1000); // wait a second
digitalWrite(LED_BUILTIN, LOW); // off
delay(1000);
}delay(1000) means 1000 milliseconds, one second. Write 200 and the LED blinks five times faster.

Illustration, made with AI
Illustration: in the evening, the built-in LED glows on a board connected to a laptop, beside a cup of tea.
Step 4: Change the speed
Lights and displaysBuild a small model of a real traffic light: green, flashing green, yellow, red and finally red with yellow, just like on the street.
Lights and displaysCars have green until a pedestrian presses the button. Then the cars get red, the pedestrians get green and a buzzer ticks, just like at a real crossing.
Lights and displaysAn RGB LED holds three small LEDs: red, green and blue. Mix their brightness and you get any colour, while the lamp slowly changes from one colour to the next.