Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Traffic Signal Controler using 8086 IC

Working
A one-way traffic signal, also known as a single-lane traffic signal, is a traffic control
device used at intersections or points where traffic flows in only one direction at a time.
These signals are typically found in areas where roadways are narrow or where traffic
volumes are relatively low. The operation of a one-way traffic signal is fairly straightforward,
involving three main phases: green, yellow, and red.

1. Green Phase:
- During the green phase, vehicles traveling in the direction of the green signal are allowed
to proceed through the intersection.
- Traffic signals facing the direction with the right of way (the direction with the green
signal) will display a green light, indicating to vehicles that they have the clear right of way
to proceed.
- Vehicles in the opposing direction will face a red light, signaling them to stop and yield to
the oncoming traffic.

2. Yellow Phase:
- The yellow phase serves as a warning to drivers that the signal is about to change from
green to red.
- It gives drivers an opportunity to slow down and prepare to stop safely before the signal
changes.
- In some jurisdictions, the yellow phase may be skipped altogether, particularly in areas
with low speeds or when traffic volumes are minimal.

3. Red Phase:
- During the red phase, vehicles in the direction with the red signal are required to come to
a complete stop.
- Traffic signals facing the direction with the red signal will display a red light, indicating to
vehicles that they must stop and wait for the signal to change.
- Vehicles in the opposing direction will receive a green light, allowing them to proceed
through the intersection once it is clear.

The cycle repeats itself, with the green phase alternating between the two directions of traffic
flow. One-way traffic signals help regulate traffic flow efficiently, ensuring safety and
minimizing congestion, particularly in areas with limited road space or lower traffic volumes.
Additionally, they help prevent accidents by controlling the movement of vehicles through the
intersection in a controlled manner.

Circuit Diagram

Requirements
Sr. Name Of Resource Required Quantity
no.
1 ATMEGA168-20PU IC 1
2 AVR programmer 1
3 7Segment Display 2
4 Plane PCB board 1
5 LED lights (Red,Yellow ,Green) Per 1
6 1k ohm Resisters 15
7 Connecting wires 1
Source Code

#define F_CPU 1000000UL


#include <avr/io.h>
#include <util/delay.h>

int a=0 ;

void zero(void)
{
if(a==0)
{PORTC=0b11000001;
PORTD=0b01100110;}
if(a==1)
{PORTC=0b11000001;
PORTD=0b11000110;}

void one(void)
{
if(a==0)
{PORTC=0b11010111;
PORTD=0b01100111;}
if(a==1)
{PORTC=0b11010111;
PORTD=0b11000111;}
}

void two(void)
{
if(a==0)
{PORTC=0b11100010;
PORTD=0b01100110;}
if(a==1)
{PORTC=0b11100010;
PORTD=0b11000110;}
}

void three(void)
{
if(a==0)
{PORTC=0b11000010;
PORTD=0b01100111;}
if(a==1)
{PORTC=0b11000010;
PORTD=0b11000111;}
}

void four(void)
{
if(a==0)
{PORTC=0b11010100;
PORTD=0b01100111;}
if(a==1)
{PORTC=0b11010100;
PORTD=0b11000111;}
}
void five(void)
{
if(a==0)
{PORTC=0b11001000;
PORTD=0b01100111;}
if(a==1)
{PORTC=0b11001000;
PORTD=0b11000111;}
}

void six(void)
{
if(a==0)
{PORTC=0b11001000;
PORTD=0b00100110;}
if(a==1)
{PORTC=0b11001000;
PORTD=0b10000110;}
}

void seven(void)
{
if(a==0)
{PORTC=0b11010011;
PORTD=0b00100111;}
if(a==1)
{PORTC=0b11010011;
PORTD=0b10000111;}
}

void eight(void)
{
if(a==0)
{PORTC=0b11000000;
PORTD=0b00100110;}
if(a==1)
{PORTC=0b11000000;
PORTD=0b10000110;}

void nine(void)
{
if(a==0)
{PORTC=0b11000000;
PORTD=0b00100111;}
if(a==1)
{PORTC=0b11000000;
PORTD=0b10000111;}
}

void ten(void)
{
if(a==0)
{PORTC=0b11000001;
PORTD=0b00100000;}
if(a==1)
{PORTC=0b11000001;
PORTD=0b10000000;}

void eleven(void)
{
if(a==0)
{PORTC=0b11010111;
PORTD=0b00100001;}
if(a==1)
{PORTC=0b11010111;
PORTD=0b10000001;}
}

void twelve(void)
{
if(a==0)
{PORTC=0b11100010;
PORTD=0b00100000;}
if(a==1)
{PORTC=0b11100010;
PORTD=0b10000000;}
}

void thirteen(void)
{
if(a==0)
{PORTC=0b11000010;
PORTD=0b00100001;}
if(a==1)
{PORTC=0b11000010;
PORTD=0b10000001;}
}

void forteen(void)
{
if(a==0)
{PORTC=0b11010100;
PORTD=0b00100001;}
if(a==1)
{PORTC=0b11010100;
PORTD=0b10000001;}
}

void fifteen(void)
{
if(a==0)
{PORTC=0b11001000;
PORTD=0b00100001;}
if(a==1)
{PORTC=0b11001000;
PORTD=0b10000001;}

void sixteen(void)
{
if(a==0)
{PORTC=0b11001000;
PORTD=0b00100000;}
if(a==1)
{PORTC=0b11001000;
PORTD=0b10000000;}
}

void seventeen(void)
{
if(a==0)
{PORTC=0b11010011;
PORTD=0b00100001;}
if(a==1)
{PORTC=0b11010011;
PORTD=0b10000001;}

void eighteen(void)
{
if(a==0)
{PORTC=0b11000000;
PORTD=0b00100000;}
if(a==1)
{PORTC=0b11000000;
PORTD=0b10000000;}
}

void half(void)
{
if(a==0)
{PORTC=0b11111111;
PORTD=0b00100111;}
if(a==1)
{PORTC=0b11111111;
PORTD=0b10000111;}
}

int main(void)
{
DDRC=0b11111111;
DDRD=0b11111111;

while (1)
{

if(a==0) // zebra on
{ PORTD=0b00100000;
eighteen();
_delay_ms(18000);
seventeen();
_delay_ms(18000);
sixteen();
_delay_ms(18000);
fifteen();
_delay_ms(18000);
forteen();
_delay_ms(18000);
thirteen();
_delay_ms(18000);
twelve();
_delay_ms(18000);
eleven();
_delay_ms(18000);
ten();
_delay_ms(18000);
nine();
_delay_ms(18000);
eight();
_delay_ms(18000);
seven();
_delay_ms(18000);
six();
_delay_ms(18000);
five();
_delay_ms(9000);
half();
_delay_ms(9000);
four();
_delay_ms(9000);
half();
_delay_ms(9000);
three();
_delay_ms(9000);
half();
_delay_ms(9000);
two();
_delay_ms(9000);
half();
_delay_ms(9000);
one();
_delay_ms(9000);
half();
_delay_ms(9000);
zero();
_delay_ms(9000);
half();
_delay_ms(9000);
a=1;}

if(a==1) // zebra off


{ PORTD=0b00100000;
eighteen();
_delay_ms(18000);
seventeen();
_delay_ms(18000);
sixteen();
_delay_ms(18000);
fifteen();
_delay_ms(18000);
forteen();
_delay_ms(18000);
thirteen();
_delay_ms(18000);
twelve();
_delay_ms(18000);
eleven();
_delay_ms(18000);
ten();
_delay_ms(18000);
nine();
_delay_ms(18000);
eight();
_delay_ms(18000);
seven();
_delay_ms(18000);
six();
_delay_ms(18000);
five();
_delay_ms(9000);
half();
_delay_ms(9000);
four();
_delay_ms(9000);
half();
_delay_ms(9000);
three();
_delay_ms(9000);
half();
_delay_ms(9000);
two();
_delay_ms(9000);
half();
_delay_ms(9000);
one();
_delay_ms(9000);
half();
_delay_ms(9000);
zero();
_delay_ms(9000);
half();
_delay_ms(9000);
a=0;}

}
}

You might also like