Create a set of traffic lights based on a system that changes from green to red through yellow and continues the loop after setting the length of time using a four-state system.
Proteus schematic diagram
The traffic lights project needs the following parts:
Arduino
Protoboard
Green LED
Yellow LED
Red LED
220 ohms resistor x 3
Wires
Tinkercad schematic diagram
Four-state system
Variables
Tiempo para cambio de luces
Pines de las luces
Método SETUP
Configurar los pines de los led como salida
Método LOOP
Semáforo rojo encendido
Delay - 5 segundos
Semáforo amarillo encendido
Delay - 2 segundos
Semáforo verde encendido
Apagar semáforo rojo
Apagar semáforo amarillo
Delay - 10 segundos
Semáforo amarillo encendido
Apagar semáforo verde
Delay - 2 segundos
Semáforo amarillo apagado
Arduino Code
Proteus simulation
Arduino real-life implementation