Two-Way Traffic Light System Using Two Arduino UNO Boards
by DESHBOT in Circuits > Arduino
16 Views, 0 Favorites, 0 Comments
Two-Way Traffic Light System Using Two Arduino UNO Boards
The objective of this project is to create a two-way traffic light system using two Arduino UNO boards. The two boards communicate with each other using TX and RX serial communication.
The system controls two traffic light modules so that when one side has a green signal, the opposite side has a red signal.
Supplies
2 x Deshbot shield
2 × Arduino UNO/Nano
2 × Traffic light modules
Jumper wires
Traffic Light Connections
UNO 1 – Traffic Signal 1
Traffic ModuleArduino UNO 1
Red - A0
Yellow - A1
Green - A2
GND - GND
UNO 2 – Traffic Signal 2
Traffic ModuleArduino UNO 2
Red - A0
Yellow - A1
Green - A2
GND - GND
UNO-to-UNO Communication
The two Arduino boards communicate using their hardware serial pins.
UNO 1UNO 2
TX (D1) - RX (D0)
RX (D0) - TX (D1)
GND - GND
TX is connected to RX because one board's transmitted data must be received by the other board.
Working Principle
The system operates two traffic signals in opposite phases.
Phase 1
Traffic Signal 1:
🟢 Green
Traffic Signal 2:
🔴 Red
Signal 1 allows traffic to move while Signal 2 stops traffic.
Phase 2
After 5 seconds, Signal 1 changes to yellow.
🟡 Signal 1
Signal 2 changes to green.
🟢 Signal 2
Phase 3
Signal 2 remains green for the required time while Signal 1 remains stopped.
After the cycle, the signals change again.
The Arduino boards communicate through TX/RX to coordinate the traffic lights.
Timing
The basic timing used in the project is:
SignalTime
Green
5 seconds
Yellow
2 seconds
Red
Depends on opposite signal
The cycle continuously repeats.
Example
This creates an alternating traffic flow.
Communication
Serial communication is used to send commands between the two Arduino boards.
For example, UNO 1 can send:
The second UNO receives the command and sets its traffic light to red.
Another command can tell the second UNO to change to green.
Conclusion
This project demonstrates a simple two-way traffic light control system using two Arduino UNO boards. The boards communicate using TX, RX, and GND, allowing the two traffic signals to operate in opposite phases. It demonstrates basic traffic control, timing, and serial communication between microcontrollers.