Report
Report
Submitted To:
Ma’am Sadia Latif
Submitted By:
GROUP # 4
Problem Statement:
Design and Implementation of a Traffic Light Controller using
Sequential Circuits
Traffic lights are critical in controlling traffic flow and ensuring road safety at
intersections. This project aims to design and implement a simple traffic light
controller using sequential circuits such as flip-flops and counters. The
system should simulate the operation of a standard traffic light, switching
between green, yellow, and red lights for two intersecting roads (e.g., Road A
and Road B) based on a defined timing sequence.
Requirements:
1. Basic Functionality:
o The traffic lights must control two roads (A and B).
o Each road must have three lights: green, yellow, and red.
o Only one road can have a green light at any given time, while the
other road shows a red light.
2. Timing Control:
o The system must follow a fixed timing sequence:
Green: 10 seconds
Yellow: 2 seconds
Red: 12 seconds (while the other road's green and yellow
are active).
3. Circuit Design:
o The design must use flip-flops (e.g., D, JK, or T) and counters to
implement the state transitions.
o The circuit must have a clock signal to synchronize state changes.
4. State Transitions:
o Define the states for the traffic light (e.g., Road A green, Road A
yellow, Road B green, Road B yellow).
o Ensure proper sequencing of lights using a state diagram and
truth table.
5. Reset Functionality:
o The system must include a reset button to restart the traffic light
sequence from an initial state.
6. Scalability:
o The design should be modular to allow future expansion, such as
adding pedestrian signals or more roads.
Working Mechanism:
The traffic light controller operates based on a predefined sequence of states,
which dictate the on/off status of the green, yellow, and red lights for two
intersecting roads. Sequential circuits, such as flip-flops and counters, are
used to implement these states and control the transitions.
2. Counters:
o Count clock pulses to control the timing for each light.
o For example, a 10-second green light can be achieved by
counting 10 pulses of a 1-second clock.
3. Flip-Flops:
o Store the current state of the traffic light system.
o Transition between states based on the clock signal and input
conditions.
4. State Diagram:
o Defines the sequence of states for the system:
1. Road A: Green → Yellow → Red
2. Road B: Green → Yellow → Red
o Ensures no conflicting states occur (e.g., both roads cannot have
green lights simultaneously).
5. Logic Gates:
o Implement the state transition logic.
o Drive the outputs for the green, yellow, and red lights based on
the current state
int Mode=0;
int Second=0;
word MilliSecond=0;
pinMode(s1_r, OUTPUT);
pinMode(s1_y, OUTPUT);
pinMode(s1_g, OUTPUT);
pinMode(s2_r, OUTPUT);
pinMode(s2_y, OUTPUT);
pinMode(s2_g, OUTPUT);
pinMode(s3_r, OUTPUT);
pinMode(s3_y, OUTPUT);
pinMode(s3_g, OUTPUT);
pinMode(s4_r, OUTPUT);
pinMode(s4_y, OUTPUT);
pinMode(s4_g, OUTPUT);
Second = Y_time;
yellow(Mode);
delay(100); // Waiting for a while
}
void loop(){
delay(10);
}
digitalWrite(s2_r, 1);
if(y==2){digitalWrite(s2_y, 1);}
else{digitalWrite(s2_y, 0);}
digitalWrite(s2_g, 0);
digitalWrite(s3_r, 1);
if(y==4){digitalWrite(s3_y, 1);}
else{digitalWrite(s3_y, 0);}
digitalWrite(s3_g, 0);
digitalWrite(s4_r, 1);
if(y==6){digitalWrite(s4_y, 1);}
else{digitalWrite(s4_y, 0);}
digitalWrite(s4_g, 0);
}
digitalWrite(s1_y, 0);
if(Set==1){digitalWrite(s1_g, 1); digitalWrite(s1_r, 0);}
else{digitalWrite(s1_g, 0); digitalWrite(s1_r, 1);}
digitalWrite(s2_y, 0);
if(Set==3){digitalWrite(s2_g, 1); digitalWrite(s2_r, 0);}
else{digitalWrite(s2_g, 0); digitalWrite(s2_r, 1);}
digitalWrite(s3_y, 0);
if(Set==5){digitalWrite(s3_g, 1); digitalWrite(s3_r, 0);}
else{digitalWrite(s3_g, 0); digitalWrite(s3_r, 1);}
digitalWrite(s4_y, 0);
if(Set==7){digitalWrite(s4_g, 1); digitalWrite(s4_r, 0);}
else{digitalWrite(s4_g, 0); digitalWrite(s4_r, 1);}
ISR(TIMER1_COMPA_vect){
MilliSecond++;
if(MilliSecond >= 1000){MilliSecond = 0;
Second = Second-1;
}
}
CIRCUIT DIAGRAMS:
schematic diagram
HARDWARE IMPLEMENTATION:
COMPONENTS USED:
1. Arduino Uno
2. Breadboard (Protoboard)
3. LEDs (Red, Yellow, Green)
4. Resistors
5. Power Supply
6. Wires and Connectors