"Traffic light" project extension to include a set of pedestrian lights and a button to request crossing the road. The Arduino will react when pressing the button, changing the state of the lights, forcing the cars to stop, and allowing a safe crossing.
Schematic diagram
The interactive traffic lights project needs the following parts:
Arduino
Protoboard
Green LED x 2
Yellow LED
Red LED x 2
330 ohms resistor x 5
10 kohms resistor
Pushbutton
Wires
Variables
Pines luces carro
Pines luces peatones
Pin del botón
Tiempo de cruce para peatones
Ciclo de terminación del paso a peatones
Método SETUP
Configurar los pines de los led como salida
Configurar el pin de botón como entrada
Inicializar las luces de carro y de peatón a verde
Método LOOP
Verificar el estado del botón
Botón presionado & tiempo paso peatones
Llamar función cambio de luces
Método CAMBIO DE LUCES
Cambio de luces vehiculares
Apagar verde, prender amarillo, retraso
Apagar amarillo, prender rojo, retraso
Apagar rojo peatones, prender verde peatones,
retraso de peatones
Parpadeo para luces de peatón
Prender rojo peatón, retraso
Prender amarillo, apagar rojo, retraso
Apagar amarillo, prender verde, retraso
Grabar el tiempo desde el último cambio de luces
Arduino Code
Proteus simulation
Arduino real-life implementation