You are on page 1of 40

TRAFFIC LIGHT CONTROLLER

(FOUR WAYS)
A PROJECT REPORT
Submitted by

RAHUL KUMAR YADAV


RAJ KUMAR YADAV
KULDEEP KUMAR YADAV
RAHUL GUPTA
In partial fulfillment for the award
Of

THREE YEAR DIPLOMA IN ELECTRONICS

ENGINEERING

JANTA POLYTECHNIC JAHANGIRABAD (BULANDSHAHR)


UTTAR PRADESH

BOARD OF TECHNICAL EDUCATION UTTAR


UNDER THE ABLE GUIDENCE OF

H.O.D.

Dr.B.Singh

Er.Naresh Bansal

(Ph.d)

(B.E. Electronics)

2014-2015

PRADESH

BONAFIDE CERTIFICATE

Certified

that

Mr.RAHUL

KUMAR

YADAV,Mr.RAJKUMAR

YADAV,Mr.KULDEEP KUMAR YADAV&Mr.RAHUL GUPTA has carried


out the research work presented in this project entitled TRAFFIC LIGHT
CONTROLLER for the award of Three year Diploma from Uttar Pradesh
Board of Technical Education, Lucknow under my supervision. The project
embodies result of original work and studies carried out by Student himself and
the contents of the project do not form the basis for the award of any other degree
to the candidate or to anybody else.

Guided by.

H.O.D

Dr.B.Singh
Bansal

Er.Naresh

(Ph.d)
Electronics)

(B.E.

ABSTRACT

This Project report describes about the steps followed for making of the project. It also elaborates
the technical details of components and devices used in this project. There are some changes
made in this project to resolve various technical problems and also to keep this project in the
estimate cost.
The main idea behind this project is all about the different applications of a micro-controller. One
of them is implemented here. It also helps us to understand the working of the micro-controller,
which can be used in future applications of the micro-controller.

Author

ACKNOWLEDGEMENT
This report is about the implementation of micro-controller as a traffic light controller. We have received
support and valuable guidance of our faculty Dr.B.Singh. We would like to thank him for his support for
us. We would also like to thank Er. V.K. Sharma the lecturer of Micro processor subject. He helps to
understand the working of the micro-controller so we implement our design around it.
We have great respect to our teachers who guide us throughout the project and helped us in achieving
our goal.

Author

TABLE of CONTENTS

CHAPTER NO.
PAGE NO.

1.

TITLE

INTRODUCTION

1.1 Aim
1
1.2 General description of Entire system
1
1.3 Working principle
1
1.4 Micro-controller AT89S51s general circuit
1
1.5 7-segment display circuit
2
2.

ATMEL AT89S51 MICRO-CONTROLLER


4
2.1 Introduction
2.2 General description
4
2.3 Time base generation with AT89s51
6
2.4 Interfacing of 7-segment display
6
2.5 Conclusion
6

3.

7-SEGMENT DISPLAY
7

3.1 Introduction

3.2 Concept and visual structure

3.3 displaying of numbers

3.4 conclusion
9

4.

REGULATED POWER SUPPLY


10
4.1 Introduction

10

4.2 General description


10
4.3 Regulator Ic-7805
10
4.4 Current limiting
5.

12

PIEZO BUZZER
13
5.1 Introduction

13

5.2 General description


13
5.3 Working of Buzzer
14
6.

TRAFFIC LIGHTS CONTROLLER


15
6.1 Introduction

15

6.2 General description


15
6.3 Schematics
16
7.

TESTING AND MEASUREMENT


17
8.1 Introduction

17

8.2 General description


18
8.3 Testing of time base signal
18
8.4 Measurement of supply voltage
19
8.5 Measurement of circuit current
19
8.6 Conclusion
20
8.

COSTING OF PROJECT
21
9.1 Introduction

21

9.2 Estimate cost

21

9.3 Real cost of project


22
9.4 Conclusion
23
10.

FIRMWARE

24

INTRODUCTION

AIM:This Project aims to develop a Traffic light controller with less complicated circuit. To make it
less complicated and less expensive Micro-controller is used in this project. We have also achieved our
secondary aim of embedded electronics by using Micro-controller for time generation and drive the
display. Use of Micro-controller makes this project less expensive, less in size, and very low power
consuming circuit.

GENERAL DESCRIPTION OF ENTIRE SYSTEM:This entire system is basically based on AT89s51 micro-controller. This micro-controller is used
to generate the time base signal, Micro-controller is programmed to drive the 7-segment display directly
by connecting to pins of micro-controller.
AT89s51 is also programmed to generate the traffic signal which provides traffic controlling
capability to the project. Thus entire system of Traffic light controller works.

WORKING PRINCIPAL:Atmel AT89s51micro-controller is programmed to obtain the time base signal and operate the
display. A 12 MHz crystal oscillator produces 1 micro second delay for one machine cycle. The Timer of
AT89s51 is used to produce the delay which further processed by AT89s51 to generate the necessary
signals for operation of Traffic lights and Timer display. 7 segment display is connected according to
active low logic and display the digits of Time remaining to change the signal. A dc piezo buzzer can be
used in further developments to provide audio alarm facility.
Traffic light system was one of the fascinating applications of Embedded systems and have been using the
same till this day. I have previously posted a simple Traffic light systemfor one way roads with small
timings check it out if you are interested in it. This is the four way traffic light system using embedded
systems which was bit complex in nature as we need to consider the traffic flow in four different
directions providing appropriate timings to each of the lights.
This system uses 8051 microcontroller (
AT89C52) , 7-segments and LED's for indication. The LED's which was used as lights was connected to
the Microcontroller by means of common Anode configuration. In this configuration the Microcontroller
was used to sink the current from the LED to its ports. That means logic 0 signal in the Microcontroller
switches the LED ON and logic 1 signal switches the LED off. Here we are using 6 MHz crystal for the
8051 Microcontroller operation and you can use upto 12MHz crystal with this controller.

MICRO-CONTROLLER AT89S51S GENERAL CIRCUIT:AT89s51 is a 40 pin micro-controller. Pin no. 20 is used for ground power supply to the microcontroller, while pin no. 40 is used for Vcc. Pin no. 9 is reset interrupt, micro-controller reset itself when
this pin becomes high with respect to the ground pin.
The pin no. 31 is known as EA i.e. external access enables. This pin should be high to run the
micro-controller if it is low then it will set the micro-controller to access the external program memory.

7-SEGMENT DISPLAY CIRCUIT:7 segment displays are used to display the numeric data. We can display all the digits from 0-9 with the
help of 7-segment display.
There are two types of displays available the common cathode and common anode. The common cathode
is used for active low logic while common anode is used for active low logic.
In this project common anode formation of 7-segment display is used to interface with micro-controller.
So Micro-controller can drive the display directly and less complicated circuit is achieved.

Fig 1.7.1

ATMEL AT89S51 MICRO-CONTROLLER

INTRODUCTION:Atmel AT89s51 is a 8-bit micro-controller based on 8051 micro-controller family. It has 40 pin package.
AT89s51 has 32 general purpose I/O pins.
These pins are divided into 4 different ports. Each port contains 8 pins. AT89s51 is a low power
application micro-controller, which makes it useful for low power application for embedded projects.

GENERAL DESCRIPTION:The AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of In-System
Programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory
technology and is compatible with the indus-try-standard 80C51 instruction set and pin out.
The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional
nonvolatile memory pro-grammer. By combining a versatile 8-bit CPU with In-System Programmable Flash on a
monolithic chip, the Atmel AT89S51 is a powerful microcontroller which provides a highly-flexible and costeffective solution to many embedded control applications.

The AT89S51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O
lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a five-vector two-level interrupt architecture,
a full duplex serial port, on-chip oscillator, and clock circuitry.
In addition, the AT89S51 is designed with static logic for operation down to zero frequency and supports
two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM,
timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM
con-tents but freezes the oscillator, disabling all other chip functions until the next external interrupt or hardware
reset.

TIME BASED TRAFFIC SIGNALLING GENERATION WITH AT89S51:To generate the time base traffic signal we have used one of the timers of AT89s51. Timer0 is used on
mode 2. It is programmed to count up to 200 which provides delay of 200 micro seconds with 12 MHz operating
clock.
Timer0 work as an interrupt, which is further used for providing the 1 second delay and increments the
second variable. Or ee can also profuce delay by counting method as used in this project.

INTERFACING OF 7-SEGMENT DISPLAY:The 7-segment display is directly interfaced with AT89s51. The display we have used here is common
anode. As AT89s51 is working on active low logic, according to this LED will glow when O/P on pin is low.
The unit digit display is connected to pin no. 0-6 of port 1. The decade digit is connected to pin 1-7 of
port 3
These two display displays the time for changing the signal. Time displayed is in seconds.

CONCLUSION:It is clear that micro-controller can be used for time based applications. With the help of good
programming more accurate time generation circuits can be implemented with low cost and low power
consumption. Also by using a micro-controller there is no need of other supporting ICs.

7-SEGMENT DISPLAY

INTRODUCTION:A seven-segment display(SSD), or seven-segment indicator, is form of electronic display device for
displaying decimal numerals that is an alternative to the more complex dot matrix displays.
Seven-segment displays are widely used in digital clocks, electronics meters, and other electronics
devices for displaying numerical information.

CONCEPT AND VISUAL STRUCTURE:The seven elements of the display can be lit in different combinations to represent the Arabic numerals.
Often the seven segments are arranged in an oblique arrangement, which aids readability.
The numerals 6, 7 and 9 may be represented by two or more different glyphs on seven-segment displays,
with or without a tail. The seven segments are arranged as a rectangle of two vertical segments on each side with
one horizontal segment on the top, middle and bottom. Additionally, the seventh segment bisects the rectangle
horizontally.

The segments of a 7-segment display are referred to by the letters A to G, where the optional DP decimal
point (an eight segment) is used for the display of non-integer numbers.

DISPLAYING NUMBERS:Seven-segment displays can display 0-9 numbers. To display a specific digit, related segments of the
display turned on and off e.g. to display digit 2 on display, segments C and F are turned OFF and rest of the
segments are turned ON.

Digits

Abcdefgh
0
1
2
3
4
5
6
7
8
9

0x7E
0x30
0x6D
0x79
0x33
0x5B
0x5F
0x70
0x7F
0x7B

B
1
0
1
1
0
1
1
1
1
1

C
1
1
1
1
1
0
0
1
1
1

D
1
1
0
1
1
1
1
1
1
1

E
1
0
1
1
0
1
1
0
1
1

F
1
0
1
0
0
0
1
0
1
0

G
1
0
0
0
1
1
1
0
1
1

0
0
1
1
1
1
1
0
1
1

CONCLUSION:We can say that seven-segment displays are ideal for displaying the numbers. As the seven segment
displays consist of any light source e.g. LED, LCD etc. they are easy to build and implement.
Seven segment display is compatible for this project as the main task here is to display the time in form of
digits, which can be done by using seven segment at ease.

REGULATED POWER SUPPLY

INTRODUCTION:A regulated power supply is an embedded circuit, which often used to provide the regulated DC supply
from the AC source or fluctuating DC source.
It converts AC into DC and provides a constant voltage (or less current) to be used in certain needed
power supply applications.

GENERAL DESCRIPTION:Regulated power supply contains rectifier for rectifying the AC supply, filter to filter the AC from output,
voltage regulator which regulates the voltage and provide the voltage of desired level, current limiter to limit the
maximum current consumption of circuit.
In this project we need only voltage regulator and current regulator to provide the constant level DC to
the Micro-controller and protect it from current over drawn by LEDs.

REGULATOR IC-7805:7805 is a voltage regulator ic, which provides power supply of 5 volts and maximum current drawn is 1
amp. 7805 is a self-contained fixed linear voltage regulator integrated circuit. 7805 have three terminals.
Terminal 1 is for input, terminal 2 is GND and terminal 3 is output terminal. 7805 do not require
additional components to provide a constant, regulated source of power. The input voltage must be higher than the
output voltage typically 2.5 volts. So the minimum input voltage for 7805 should be 7.5 volts.
7805 is positive regulator, which means it use negative supply as ground and positive supply is connected
to input.

ZENER DIODE REGULATOR:Zener diodes also can be used for voltage regulation. Here we have used 5v1 zener to
regulate our voltage to a significant level of 5.1 volt.

Zener should be connected in reverse bias mode.


CURRENT LIMITING:Current limiting is the practice in electrical or electronics circuits of imposing an upper limit on the
current that may be delivered to a load with the purpose of protecting the circuit generating or transmitting the
current from harmful effects due to a short-circuit or similar problem in the load.
Instead of using NPN or PNP transistors for current limiting, we have used preset for this purpose. Preset
is connected in series with at output of 7805 IC. It limits the current via voltage drop across the preset and also
provides a constant voltage level for micro-controller for operation, making it extremely low power consuming
device.

PIEZO BUZZER

INTRODUCTION:-

Piezo buzzer is an electronic device commonly used to produce sound. Light weight, simple construction
and low price make it useable in various applications like vehicle reversing indicator, computers, call bells etc.
There are two types of buzzers available i.e. DC and AC. We have used DC buzzers here they produce
beep sound when a DC voltage is applied to it. This function makes it useable for alarm application of our project.

GENERAL DESCRIPTION:Piezo is based on the inverse principle of piezo electricity discovered in 1880 by Jacques and
pierre curie. It is the phenomena of generating electricity when mechanical pressure is applied to certain
materials and the vice versa is also true.
Such materials are called piezo electric materials. Piezo electric materials are either naturally
available or manmade. Piezoceramic is class of manmade material, which poses piezo electric effect and
is widely used to make disc, the heart of piezo buzzer.
When subjected to an alternating field they stretch or compress, in accordance with the frequency
of signal thereby producing sound.

WORKING OF BUZZER:-

When a small DC voltage is applied to the input pins, it is first converted to an oscillating signal
using the combination of resistor and transistor.
These oscillating signals are amplified using the inductor coil. When high voltage alternating
signals are applied to the piezo ceramic disc, it causes mechanical expansion and contraction in radial
direction.
This causes the metal plate to bend in opposite direction. When metal plate bends and shrinks in
opposite direction continuously it produces sound waves in the air.

TRAFFIC LIGHT CONTROLLER

INTRODUCTION:The entire project is based on AT89s51 micro-controller. This digital clock circuit contains the
seven-segment display, micro-controller, regulated power supply and buzzer.
Micro-controller handles multiple tasks which makes this circuit small and low power
consuming. It also drives the display directly and provides the alarm facility. The entire circuit is designed
for consuming less space and minimum components.

GENERAL DESCRIPTION:Micro-controller and its supporting components form the base for the circuit of the digital clock.
To make the display LEDs are used. These LEDs are connected in common anode formation.
The 7805 IC and preset form the regulated power supply along with the power source such as
battery or DC adaptor.
The piezo buzzer produces sound for alarm applications. So it is connected to the microcontroller and also driven by it.
The general purpose PCB provides the solid base for the clock circuit and components. All the
components and ICs are soldered on PCB and Traffic lights controller is made out.
The above diagram illustrates the traffic flow layout of the four way road. And this is just a model of the
four way road ,schemes and layout may subjected to change. I have chose this one for easier explanation
of the traffic flow.
The traffic flow can be classified in to four phases in the above diagram and i have considered the North
as starting point of this traffic flow. And in the above scheme vehicles are allowed to make a free left turn

so we need to consider only two directions straight and right. So the green signal was classified into two
types one for G for permitting vehicle to proceed forward and GR for permitting vehicles to right.

PHASE I*.Initially Vehicle from A needs to travel to F and from E to B roads.


*.So in the first Phase forward green signal in A and E permits vehicles to pass through while East and
west roads are stopped by red signal.
PHASE II*.Phase II permits the vehicle to pass from G to D and from C to H roads.
*.Traffic flow from rest of the two roads North and south was stopped by means of Red signal.
PHASE III*.Phase three permits traffic flow in the left directions from A to D and from E to H.
*.Traffic flow in East and west are stopped by means of red signal.

PHASE IV*.Phase four permits traffic flow from C to F and from G to B.


*.Traffic flow in the North and south are stopped by means of red signal.
*.The cycle repeats again from Phase I to Phase IV and thus the traffic is regulated.

SCHEMATICS:-

COMPONENT LAYOUT DIAGRAM OF PCB

INTRODUCTION:-

A printed circuit board (PCB) mechanically supports and electrically connects electronic components
using conductive tracks, pads and other features etched from copper sheets laminated onto a non-conductive
substrate.
PCBs can be single sided, double sided or multi layer. Conductors on different layers are connected with
plated-through holes called vias. Advanced PCBs may contain components- capacitors, resistors or active devicesembedded in substrate.

LAYOUT DIAGRAM:-

TESTING AND MEASUREMENT

INTRODUCTION:Testing and measurement is a crucial part of electronics system design. This process is done to check the
faults in the circuit and verify that if it is working correctly not. Measurement is an essential part of this process.
We measure the voltage, current, resistance and capacitance of components to standard desired value as per the
circuit requirements.
There are many types of equipment used in this process. Some of them are multimeter, frequency
counter, oscilloscope etc. Thus by testing and measurement we can examine the results of our test and compare
them to standard results, so we can get the desired results and enhance the performance of the circuit.

GENERAL DESCRIPTION:According our project we only need multimeter, frequency counter, oscilloscope to test and measure our
circuit. First to check the circuit connections we use the continuity feature of multimeter. Oscilloscope is used to
test and measure the crystal used in circuit to run the micro-controller.

Power supply voltages are tested with multimeter and circuit current consumption also tested and should
not exceed the maximum limit of micro-controller. All the LEDs are tested with multimeter using diode testing
probe.

TESTING OF TIME BASE SIGNAL:Time base signal is generated with the help on one of the two timers of AT89s51 micro-controller. A one
second delay is produced by programming. This is the base signal for our clock and has to be tested for accurate
delay.
To test this signal frequency counter is used. First we write a program using the time base signal
generation part and assign the second delay variable to a pin of micro-controller as output. Then frequency
counter is calibrated with this for testing of signal. The frequency of the signal should be 1 Hz. Thus time base
signal is verified and used in program for producing the accurate delay.

MEASUREMENT OF SUPPLY VOLTAGE:Supply voltage of the circuit should be in limits. Otherwise it may damage the various components. As
per the power ratings of the components used in this circuit the voltage should not cross the 3 volts limits as LEDs
used here only can bear voltages up to 3 volts. Meanwhile voltage should not be less than 2 volts as microcontroller we used here cant run properly under this voltage can causes some operation issues.
So the multimeter is connected in parallel with power supply. We can control the voltage using preset.
The voltage set here is 2.7 volts. Multimeter tested the voltage and this should be as per the requirements which
are 2.7 volts.

MEASUREMENT OF CIRCUIT CURRENT:-

The total current drawn by circuit is considered as circuit current. This current should be regulated for
protection of various devices and components used in the circuit.
In this project micro-controller current limitations are considered as circuit current limit, as microcontroller driving the various supported devices directly. The maximum current rating for the circuit is 50 mA.
To measure the current drawn by the circuit, the multimeter is connected in series with power supply. We
can limit the current drawn by the circuit by using the given preset at power regulation stage. The current should
be under the 50 mA. In this project current is kept nearly 40-45 mA.

CONCLUSION:Testing & measurement helps us to obtain the desired results and also tells about the properties of various
components. In this project by performing the above steps we have ensured that our circuit does not have any
faults or problems. We also get know about the limitations of this circuit.
After observing the above results we found that the results are satisfactory as the standard results
assumed.

COSTING OF PROJECT

INTRODUCTION:The costing and expenditure evaluation of the project is a very important part. In this gross project cost is
estimated by assuming the price of various components, services and other expenses related to the project.
Costing or expenditure evaluation gives a specific idea about the cost of the project when it is completed
even before it getting started. This process helps us to keep our project cheaper or less expensive. It also inform
about the money needed for the project to be completed.

ESTIMATE COST:The estimate cost of the project along with the individual components cost is mentioned below in the
table.

Items

Type

Quantity

Price per unit

Total price

Capacitor
Preset
Crystal oscillator
IC base
IC 7805
LED
Buzzer
PCB
IC AT89s51
Wires
Switch
Battery

22 pf
5k
12 MHz
40 pin

2
1
1
1
1
12
1
1
1
1
4
1

3
10
25
10
10
3
20
25
120
15
5
25

6
10
25
10
10
36
20
25
120
15
20
25
322

Red, Amber, Green


DC
General purpose
DIP package
Aluminum
momentary
9 volts

TOTAL COST

REAL COST:The project is completed under the project cost estimates and achieved the goal by keeping it total cost
under the estimations. The real cost of the project and individual components are mentioned below in the table.

Items

Type

Capacitor
Preset
Crystal oscillator
IC base
IC 7805
LED
Buzzer
PCB
IC AT89s51
Wires
Switch

22 pf
5k
12 MHz
40 pin

Quantity

2
1
1
1
1
Red, Amber, Green 12
DC
1
General purpose
1
DIP package
1
Aluminum
1
momentary
4

Price per unit

Total price

3
8
20
10
10
3
15
20
110
15
3

6
8
20
10
10
36
15
20
110
15
12

Battery

9 volts

20

TOTAL COST

20

227

CONCLUSION:The project is completed under the estimates of the project cost. The main reason for low cost of the
project is use of LEDs instead of display modules to display the digits and data.
The project achieved its goal of low cost with rich features.

FIRMWARE

The coding was done using Embedded C language using IDE 8051
software. The code was given below.

1.#include<stdio.h>
2.#include<reg51.h>
3.void delay(void);
4.void count1(void);
5.void count2(void);
6.sbit NR=P0^0; sbit NY=P0^1; sbit NG=P0^2; sbit NGL=P0^3;//Setting
bit for LED's north
7.sbit SR=P0^4; sbit SY=P0^5; sbit SG=P0^6; sbit SGL=P0^7;//Setting
Bit for LED's South
8.sbit ER=P1^0; sbit EY=P1^1; sbit EG=P1^2; sbit EGL=P1^3;//Setting
Bit for LED's East
9.sbit WER=P1^4; sbit WEY=P1^5; sbit WEG=P1^6; sbit
WEGL=P1^7;//Setting Bit for LED's west
10.unsigned char
a[10]={0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x3f};//Array for
displaying digits on segment 1,2.......9,0
11.unsigned char b[7]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d};//Array for
displaying 0 to 6
12.unsigned int i,j,s,k;//Assigning Integers

13.void main()//Main program


14.{
15.NR=1; NY=1; NG=0; NGL=1;// I phase forward green for north lights
16.SR=1; SY=1; SG=0; SGL=1;// forward green for south lights
17.ER=0; EY=1; EG=1; EGL=1;//Red signal for east
18.WER=0; WEY=1; WEG=1; WEGL=1;//Red signal for west lights
19.{
20.count1();//Calling out subroutine to display digits in 7segment
21.}
22.NR=1; NY=1; NG=0; NGL=1;//I phase yellow signal
23.SR=1; SY=1; SG=0; SGL=1;
24.ER=1; EY=0; EG=1; EGL=1;
25.WER=1; WEY=0; WEG=1; WEGL=1;
26.{
27.count2();//Calling out sub routine for displaying counts for yellow
28.}
29.NR=0; NY=1; NG=1; NGL=1;//II phase red signal for north lights

30.SR=0; SY=1; SG=1; SGL=1;


31.ER=1; EY=1; EG=0; EGL=1;
32.WER=1; WEY=1; WEG=0; WEGL=1;
33.{
34.count1();
35.}
36.NR=1; NY=0; NG=1; NGL=1;//II phase yellow lights for North and
south
37.SR=1; SY=0; SG=1; SGL=1;
38.ER=1; EY=1; EG=0; EGL=1;
39.WER=1; WEY=1; WEG=0; WEGL=1;
40.{
41.count2();
42.}
43.NR=1; NY=1; NG=1; NGL=0;//III phase Green left for north and
south
44.SR=1; SY=1; SG=1; SGL=0;
45.ER=0; EY=1; EG=1; EGL=1;

46.WER=0; WEY=1; WEG=1; WEGL=1;


47.{
48.count1();
49.}
50.NR=1; NY=1; NG=1; NGL=0;//III phase yellow lights
51.SR=1; SY=1; SG=1; SGL=0;
52.ER=1; EY=0; EG=1; EGL=1;
53.WER=1; WEY=0; WEG=1; WEGL=1;
54.{
55.count2();
56.}
57.NR=0; NY=1; NG=1; NGL=1;//IV phase Red signal for North and
south
58.SR=0; SY=1; SG=1; SGL=1;
59.ER=1; EY=1; EG=1; EGL=0;
60.WER=1; WEY=1; WEG=1; WEGL=0;
61.{

62.count1();
63.}
64.NR=1; NY=0; NG=1; NGL=1;//IV phase Yellow signal for north and
south
65.SR=1; SY=0; SG=1; SGL=1;
66.ER=1; EY=1; EG=1; EGL=0;
67.WER=1; WEY=1; WEG=1; WEGL=0;
68.{
69.count2();
70.}
71.}
72.void count1(void)//Sub routine for displaying numbers in segments for
red signal
73.{
74.P2=0x3f;
75.for(j=0;j<=4;)
76.{
77.for(i=0;i<=8;)

78.{
79.P3=a[i];
80.i++;
81.delay();
82.}
83.j++;
84.P2=b[j];
85.P3=0x3f;
86.delay();
87.}
88.}
89.void count2(void)//Sub routine for displaying numbers in segments for
yellow signal
90.{
91.P2=0x3f;
92.for(i=0;i<=8;)
93.{

94.P3=a[i];
95.i++;
96.delay();
97.}
98.P2=0x06;
99.P3=0x3f;
100.delay();
101.}
102.void delay(void)//Sub routine for creating delay
103.{
104.for(s=0;s<=230;s++)//Creating delay using number count
105.{106.for(k=0;k<1000;k++);
107.}
108.}

You might also like