N-Way Traffic Light System Using Arduino Uno
Components Required
Component Specification Quantity Purpose
ATmega328P, 16MHz, 14 Digital I/O
Arduino Uno 1 Main microcontroller
pins
Detection range: 2-30cm, 5V Vehicle presence
IR Sensors 4
operating detection
Ultrasonic Sensors (HC- Traffic density
Range: 2-400cm, 5V, 40kHz 4
SR04) measurement
LEDs - Red 5mm, Forward voltage: 2.0V 4 Stop signal indication
LEDs - Yellow 5mm, Forward voltage: 2.1V 4 Caution signal indication
LEDs - Green 5mm, Forward voltage: 3.2V 4 Go signal indication
Resistors 220Ω, 1/4W, 5% tolerance 12 Current limiting for LEDs
Breadboard 830 tie points 1 Component mounting
30
Jumper Wires Male-to-male, various colors Circuit connections
pieces
Power Supply 9V battery or USB 5V 1 System power
Push Button Momentary switch, 5V 1 Emergency override
7-Segment Display Common cathode, 0.56 inch 1 Timer display
Input and Output Description
Inputs
Input Type Source Function Pin Assignment
Detects vehicle presence at
Vehicle Detection IR Sensors (4x) Digital pins 2, 3, 4, 5
lane entry
Distance Ultrasonic Sensors Trigger: 6,7,8,9 Echo:
Measures traffic queue length
Measurement (4x) 10,11,12,13
Emergency Override Push Button Manual emergency control Digital pin A0
Power Supply 9V Battery/USB System power input VIN/5V pin
Outputs
Output Type Component Function Pin Assignment
North Traffic Lights 3 LEDs (Red, Yellow, Green) Controls north-bound traffic Digital pins A1, A2, A3
South Traffic Lights 3 LEDs (Red, Yellow, Green) Controls south-bound traffic Digital pins A4, A5, 2
East Traffic Lights 3 LEDs (Red, Yellow, Green) Controls east-bound traffic Digital pins 3, 4, 5
West Traffic Lights 3 LEDs (Red, Yellow, Green) Controls west-bound traffic Digital pins 6, 7, 8
Timer Display 7-Segment Display Shows countdown timer Digital pins 9, 10, 11, 12
Applications
Primary Applications
Urban Intersections: High-traffic city center traffic management
Suburban Areas: Moderate traffic control with cost-effective implementation
School Zones: Enhanced safety with adaptive timing during school hours
Hospital Areas: Priority routing for emergency vehicles
Specialized Applications
Construction Zones: Temporary traffic management during road work
Special Events: Dynamic traffic control for concerts, sports events
Smart Cities: Integration with IoT infrastructure and city-wide networks
Developing Regions: Affordable alternative to expensive traditional systems
Advanced Applications
Emergency Services: Automatic priority for ambulances, fire trucks, police
Public Transportation: Bus priority systems for improved transit efficiency
Pedestrian Safety: Integration with crosswalk signals and timers
Data Collection: Traffic pattern analysis for urban planning
Circuit Diagram
Arduino based 4-way traffic light control system with circuit diagram, components, and Proteus
simulation illustrating traffic signal operation.
Pin Configuration
Arduino Uno Pin Assignments:
North Lane: Red(A1), Yellow(A2), Green(A3)
South Lane: Red(A4), Yellow(A5), Green(2)
East Lane: Red(3), Yellow(4), Green(5)
West Lane: Red(6), Yellow(7), Green(8)
IR Sensors: Pins 2, 3, 4, 5
Ultrasonic Trig: Pins 6, 7, 8, 9
Ultrasonic Echo: Pins 10, 11, 12, 13
Emergency Button: Pin A0
Timer Display: Pins 9, 10, 11, 12
Circuit Connections
1. Power Distribution: 5V and GND from Arduino to breadboard power rails
2. LED Connections: Each LED connected through 220Ω resistor to assigned digital pin
3. Sensor Wiring: IR sensors to digital inputs, ultrasonic sensors with trigger and echo pins
4. Display Interface: 7-segment display connected to digital pins for timer function
Circuit diagram of an Arduino UNO connected to a breadboard with red, yellow, and green LEDs
arranged in three groups to simulate traffic lights, showing pin connections and resistors.
Procedure
Step 1: Hardware Assembly
1. Mount Arduino Uno on breadboard or development platform
2. Connect power rails - 5V and GND from Arduino to breadboard power rails
3. Install LEDs - Place 12 LEDs (4 red, 4 yellow, 4 green) on breadboard in groups of 3
4. Add resistors - Connect 220Ω resistor in series with each LED
5. Wire traffic lights - Connect each LED group to assigned Arduino pins
6. Install sensors - Mount 4 IR sensors and 4 ultrasonic sensors at lane positions
Step 2: Circuit Wiring
1. LED Wiring:
North: Red→A1, Yellow→A2, Green→A3
South: Red→A4, Yellow→A5, Green→2
East: Red→3, Yellow→4, Green→5
West: Red→6, Yellow→7, Green→8
2. Sensor Connections:
IR Sensors: VCC→5V, GND→GND, OUT→Digital pins 2-5
Ultrasonic: VCC→5V, GND→GND, Trig→6-9, Echo→10-13
3. Additional Components:
Emergency button: One terminal→A0, other→GND
7-segment display: Connect to pins 9-12 for timer display
Step 3: Software Programming
1. Setup Function:
void setup() {
// Initialize LED pins as outputs
for(int i = 2; i <= 8; i++) {
pinMode(i, OUTPUT);
}
pinMode(A1, OUTPUT); pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT); pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
// Initialize sensor pins
for(int i = 2; i <= 5; i++) {
pinMode(i, INPUT); // IR sensors
}
// Initialize all lights to red
setAllRed();
}
2. Main Control Loop:
void loop() {
readSensors(); // Read all sensor inputs
calculateDensity(); // Process traffic data
selectPriorityLane(); // Determine which lane gets green
controlTrafficLights(); // Set appropriate LED states
manageTimer(); // Handle countdown display
handleEmergency(); // Check for emergency override
delay(100); // Short delay for system stability
}
Step 4: Calibration and Testing
1. Sensor Calibration:
Test IR sensors for vehicle detection range
Calibrate ultrasonic sensors for accurate distance measurement
Verify sensor placement for optimal coverage
2. Traffic Light Testing:
Test each LED individually for proper operation
Verify correct color sequence (Red→Yellow→Green→Yellow→Red)
Test emergency override functionality
3. System Integration:
Test complete traffic cycle with simulated vehicles
Verify priority-based lane selection algorithm
Test emergency vehicle detection and priority override
Step 5: System Optimization
1. Timing Adjustment:
Optimize green light duration based on traffic density
Set appropriate yellow light transition time (3-5 seconds)
Configure minimum and maximum green light durations
2. Algorithm Tuning:
Fine-tune priority calculation weights
Adjust sensor sensitivity for different vehicle types
Optimize emergency detection parameters
3. Performance Monitoring:
Monitor system response times
Track traffic flow efficiency
Log system performance data for analysis
Arduino Mega based 4-way traffic light controller circuit diagram showing LEDs for signals,
resistors, power source, and connections on breadboards.
Step 6: Deployment and Maintenance
1. Installation:
Mount system in weatherproof enclosure
Position sensors at optimal locations
Connect to reliable power source
2. Operational Testing:
Test system under various traffic conditions
Verify emergency vehicle priority operation
Check system reliability over extended periods
3. Maintenance Schedule:
Regular sensor cleaning and calibration
LED replacement as needed
Software updates for improved algorithms
System performance monitoring and optimization
This comprehensive implementation guide provides all necessary details for building and
deploying an effective N-way traffic light control system using Arduino Uno, offering significant
improvements over traditional fixed-time systems while maintaining cost-effectiveness and ease
of implementation.