Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Name: Yassin Ahmad Nasr

Task 2
TRAFFIC LIGHTS Project using PIC16f877A:-

- The circuit was designed by proteus 8.3.

- A microcontroller was used int the circuit to implement the program of shifting the lights.

- The IC chip PIC16f877A was used and "mikroC pro" was used to implement that program.

- The mechanism and details of the circuit:

There are two roads intersecting each other. Each one has a traffic light, the two streets cannot
allow the cars to pass at the same time. So, the lights on the southern street should go with the
following order (23 sec 'red', 12 sec 'green', 3 sec 'yellow'), and the lights on the western street should
go with the following order (15 sec 'red', 20 sec 'green', 3 sec 'yellow'). So, the best way to apply the
best timing is to align the southern red with green and yellow of the western street, and align the red of
the western street with the green and yellow of the southern.

There is a manual mode and an automatic one, with a switch to shift between both, and there’s
another switch to shift between streets in manual mode.

- First with the hardware:

* Four decoders of model '7448' were used.

* Four NPN transistors.

* PIC16F877A.

* Six resistors were used, four of value 4.7K, two of value 10K.

* Two switches.

* Two traffic lights (six leds: two green, two yellow and two red)

* Four seven segment display.

* One push button to reset the IC chip.

* Three capacitors (two of value 33pF and one of value 100nF)

* One crystal used to compute time.

- Second with the software:


An array that contains decimal numbers that when turned to binary, the first four bits
represent the units of the counter, and the least four bits represent the tens of the counter. Port a, b, c,
d are declared outputs. And to make the counters start counting, a for loop was implemented to iterate
through the array of segments from the end (the declared starting digit) till it reaches zero , at the same
instance it turns color. In the manual mode, two while loops were made to define the two modes, each
for one street to let the cars pass and for the other to stop them. In the manual mode each street yellow
light should wait tree seconds, so, when the manual mode is applied, the selected street should remain
red until the three seconds pass and the other traffic light turns red, then the selected street can turn
green.

You might also like