Design and Implementation of a Dual-Set Traffic Light System for an Intersection
Introduction
Managing traffic flow efficiently and safely at intersections is crucial in urban planning. This lab focuses on designing and implementing a second set of traffic lights for an intersection, resulting in a dual-set traffic light system. The system comprises:
- Set 1: {R1, Y1, G1}
- Set 2: {R2, Y2, G2}
Each set controls traffic flow on perpendicular roads, ensuring synchronized and conflict-free movement. This document outlines the design process, implementation details, and justifications for the chosen approach.
Design Documentation
1. Traffic Light Sets Overview
2. State Sequence Description
The traffic light system operates in a continuous loop of six states, each lasting 3 seconds. The sequence ensures that only non-conflicting traffic flows receive green signals simultaneously.
- State 1: R1 = Red, R2 = Red
- State 2: R1 = Red, G2 = Green
- State 3: R1 = Red, Y2 = Yellow
- State 4: R1 = Red, R2 = Red
- State 5: G1 = Green, R2 = Red
- State 6: Y1 = Yellow, R2 = Red
After State 6, the sequence repeats starting from State 1.
3. Justification of Design Choices
-
Dual-Set Configuration: Having two separate sets of lights allows independent control of traffic on two intersecting roads, reducing the potential for conflicts and enhancing safety.
-
Six-State Cycle: This sequence ensures all possible traffic movements are accounted for, including necessary all-red phases to clear the intersection before changing directions.
-
Uniform Timing: Allocating 3 seconds per state provides a balanced approach suitable for low to moderate traffic volumes. Timing can be adjusted based on traffic analysis for real-world applications.
-
Standby Mode Implementation: Incorporating a standby state ensures both sets of lights can be initialized safely and can return to a safe state in case of system malfunctions.
Implementation Details
1. Hardware Components
- Microcontroller: Arduino Uno (for control logic and timing)
- LEDs:
- 6 LEDs (Red, Yellow, Green for each set)
- Resistors:
- 6 x 220 Ohms (current limiting for LEDs)
- Breadboard and Connecting Wires
- Power Supply: 5V (from Arduino)
2. Circuit Design
-
LED Connections:
- Each LED (R1, Y1, G1, R2, Y2, G2) is connected to a digital I/O pin on the Arduino through a 220 Ohm resistor to limit current and prevent damage.
-
Grounding:
- All LED cathodes are connected to the ground rail on the breadboard.
-
Pin Assignments (Example):
- R1: Pin 2
- Y1: Pin 3
- G1: Pin 4
- R2: Pin 5
- Y2: Pin 6
- G2: Pin 7
(Ensure to update the pin assignments as per your setup if necessary.)
3. Software Implementation
The microcontroller is programmed to cycle through the six states with each state lasting 3 seconds. Below is a sample Arduino code to achieve this functionality:
// Pin Definitions
const int R1 = 2;
const int Y1 = 3;
const int G1 = 4;
const int R2 = 5;
const int Y2 = 6;
const int G2 = 7;
void setup() {
// Initialize all LED pins as OUTPUT
pinMode(R1, OUTPUT);
pinMode(Y1, OUTPUT);
pinMode(G1, OUTPUT);
pinMode(R2, OUTPUT);
pinMode(Y2, OUTPUT);
pinMode(G2, OUTPUT);
}
void loop() {
// State 1: Both roads are red
digitalWrite(R1, HIGH);
digitalWrite(Y1, LOW);
digitalWrite(G1, LOW);
digitalWrite(R2, HIGH);
digitalWrite(Y2, LOW);
digitalWrite(G2, LOW);
delay(3000);
// State 2: Road R1 red, Road R2 green
digitalWrite(R1, HIGH);
digitalWrite(Y1, LOW);
digitalWrite(G1, LOW);
digitalWrite(R2, HIGH);
digitalWrite(Y2, LOW);
digitalWrite(G2, HIGH);
delay(3000);
// State 3: Road R1 red, Road R2 yellow
digitalWrite(R1, HIGH);
digitalWrite(Y1, LOW);
digitalWrite(G1, LOW);
digitalWrite(R2, HIGH);
digitalWrite(Y2, HIGH);
digitalWrite(G2, LOW);
delay(3000);
// State 4: Both roads are red
digitalWrite(R1, HIGH);
digitalWrite(Y1, LOW);
digitalWrite(G1, LOW);
digitalWrite(R2, HIGH);
digitalWrite(Y2, LOW);
digitalWrite(G2, LOW);
delay(3000);
// State 5: Road R1 green, Road R2 red
digitalWrite(R1, HIGH);
digitalWrite(Y1, LOW);
digitalWrite(G1, HIGH);
digitalWrite(R2, HIGH);
digitalWrite(Y2, LOW);
digitalWrite(G2, LOW);
delay(3000);
// State 6: Road R1 yellow, Road R2 red
digitalWrite(R1, HIGH);
digitalWrite(Y1, HIGH);
digitalWrite(G1, LOW);
digitalWrite(R2, HIGH);
digitalWrite(Y2, LOW);
digitalWrite(G2, LOW);
delay(3000);
}
Explanation of the Code:
Note: This is a basic implementation. For real-world applications, considerations such as pedestrian signals, sensor inputs, and adaptive timing would be necessary.
4. Circuit Verification
-
Power Up the System:
- Ensure that the Arduino is properly connected to the power source.
- Verify that all connections on the breadboard are secure.
-
Testing Each State:
- Observe the LEDs to confirm that only the intended lights are active in each state.
- Use a stopwatch to verify that each state lasts approximately 3 seconds.
-
Troubleshooting:
- If LEDs do not light up as expected, check the connections and ensure that resistor values are appropriate.
- Verify that the correct pins are assigned in the code matching the hardware setup.
-
Final Verification:
- Allow the system to run through multiple cycles.
- Monitor for consistent timing and correct sequencing of states.
Demonstration and TA Sign-off
After successfully building and verifying the traffic light circuit, prepare for demonstration by:
-
Presentation Preparation:
- Clearly explain the design, highlighting how each state controls traffic flow.
- Show the LED sequence in action, correlating each state with the intended traffic management strategy.
-
Circuit Layout Explanation:
- Walk through the breadboard setup, explaining the purpose of each component.
- Highlight the connections between the microcontroller and LEDs.
-
Functionality Demonstration:
- Run the system and showcase the transition through all six states.
- Emphasize the timing accuracy and the safety measures incorporated.
-
Request Sign-off:
- Once the demonstration is complete and the functioning is verified by the TA, have the TA sign the Experiment Sign-off Page to confirm successful completion.
Conclusion
The dual-set traffic light system effectively manages traffic flow on two intersecting roads by cycling through defined states, ensuring safety and efficiency. The design leverages a microcontroller for precise control and flexibility, making it adaptable for various traffic conditions. Through systematic planning, implementation, and verification, the system meets the outlined requirements and serves as a foundational model for more complex traffic management solutions.
Appendix
Circuit Diagram:
Include a schematic diagram here showing the connections between the Arduino, resistors, and LEDs for both traffic light sets.
Fritzing Example:
(A Fritzing diagram can be created and attached to visually represent the breadboard setup.)
Code Listing:
(Provide the complete Arduino code as shown above.)
Ensure to tailor the circuit diagram and labeling according to your actual setup for clarity during the demonstration.