You are on page 1of 5

COLLEGE OF AERONAUTICAL ENGINEERING

NATIONAL UNIVERSITY OF SCIENCE AND TECHNOLOGY


AV-314
EMBEDDED SYSTEMS
LAB 06

SUBMITTED TO:
LAB ENGR MUHAMAD ALI KHALID

SUBMITTED BY:
NAME: PAK NO: CMSID:282308
NAME: PAK NO: CMSID:282278
Implementation of PIC Traffic Light
Simulator
Introduction:
In this lab we have implemented a traffic light simulator using PIC 16F877A microcontroller. The
following steps were followed in the execution of this lab. Four signal were modelled in the software as
well as hardware. At one time, only one signal gave a green signal while the other three gave a red
signal. All signals gave a green signal sequentially.

Coding:
The program was written in C language using the software mikroC PRO. The following code was written:

sbit red1 at RB0_bit;


sbit yellow1 at RB1_bit;
sbit green1 at RB2_bit;
sbit red2 at RB3_bit;
sbit yellow2 at RB4_bit;
sbit green2 at RB5_bit;
sbit red3 at RB6_bit;
sbit yellow3 at RB7_bit;
sbit green3 at RC0_bit;
sbit red4 at RC2_bit;
sbit yellow4 at RC3_bit;
sbit green4 at RC4_bit;
void main()
{
TRISB=0X00;
TRISC=0X00;
while (1)
{
red1=0;yellow1=0;green1=1;
red2=1;yellow2=0;green2=0;
red3=1;yellow3=0;green3=0;
red4=1;yellow4=0;green4=0;
delay_ms(3000);
red1=0;yellow1=1;green1=0;
red2=0;yellow2=1;green2=0;
red3=1;yellow3=0;green3=0;
red4=1;yellow4=0;green4=0;
delay_ms(1000);
red1=1;yellow1=0;green1=0;
red2=0;yellow2=0;green2=1;
red3=1;yellow3=0;green3=0;
red4=1;yellow4=0;green4=0;
delay_ms(3000);
red1=1;yellow1=0;green1=0;
red2=0;yellow2=1;green2=0;
red3=0;yellow3=1;green3=0;
red4=1;yellow4=0;green4=0;
delay_ms(1000);
red1=1;yellow1=0;green1=0;
red2=1;yellow2=0;green2=0;
red3=0;yellow3=0;green3=1;
red4=1;yellow4=0;green4=0;
delay_ms(3000);
red1=1;yellow1=0;green1=0;
red2=1;yellow2=0;green2=0;
red3=0;yellow3=1;green3=0;
red4=0;yellow4=1;green4=0;
delay_ms(1000);
red1=1;yellow1=0;green1=0;
red2=1;yellow2=0;green2=0;
red3=1;yellow3=0;green3=0;
red4=0;yellow4=0;green4=1;
delay_ms(3000);
red1=0;yellow1=1;green1=0;
red2=1;yellow2=0;green2=0;
red3=1;yellow3=0;green3=0;
red4=0;yellow4=1;green4=0;
delay_ms(1000);
}
}

Circuit Model:
The circuit was modelled in proteus software and the hex file, which was created in microC PRO, was
imported into this model. Then the circuit was simulated.
Code Burning:
After successful simulation, the hex file, created previously, was burned into the microcontroller PIC
16F877A. This was done using the pickit2 software.
Hardware Implementation:
Then the physical circuit, containing the microcontroller with the hex file, was patched on a breadboard.
The circuit was run successfully.

Conclusion:
A traffic light simulator was successfully modelled on software as well as hardware using a PIC16F877A.
This enabled us to implement slightly more complex logic using PIC16F877A.

You might also like