Project to demonstrate use of multiple interrupts in a real world situation. Traffic light control with pedestrian crossing was chosen so that interrupts can be used for sensing traffic in the background and to latch in a crossing request.
For test purposes Hall Effect sensors were used in place of Push Buttons or loop sensor.
Pedestrian request is latched in and additional presses are ignored until crossing cycle completed. The crossing authority is delayed depending on what point in the light sequence the button is pressed but is limited for a max. of 2 cycles.
A second interrupt detects traffic flow to prolong green period depending on traffic volume but time limited so as not to block one way.
This project is fully scalable for full size traffic lights by using a suitable interface, relays, contactors
, and pickup loops or microwave traffic sensors. This project is for the control of one way traffic over a single lane bridge with a pedestrian crossing on one side, but could also control cross roads.
Run on ARDUINO Mega 2560.
Road Safety Logic: Traffic Light Controller
The Traffic Light Controller is a fundamental exercise in Timing Logic and Sequence Management. It mimics the real-world systems that keep our roads safe every day.
The Timing Loop
The project is more than just blinking three lights; it requires a specific sequence:
- Green: On for 5 seconds.
- Yellow: On for 2 seconds (the warning phase).
- Red: On for 5 seconds.
- Repeat: The loop ensures that the Yellow light always precedes the Red light, just like in real life.
Hardware Components
- Arduino Uno/Nano: The logic brain.
- LEDs (Red, Yellow, Green): Representing the signals.
- 220-ohm Resistors (x3): One for each LED.
- Breadboard and Jumper Wires.
Why This Project?
This is the perfect introduction to the delay() function and state management. As you advance, you can add a Pedestrian Button (using an interrupt) that forces the traffic light to turn red when someone wants to cross, making your simulation even more realistic.