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

Introduction to Embedded Systems

Practical #9
Name Jeet save Division B
Class S.Y.B.Sc.IT Roll Number 21302E3007
Practical 9 Timer Mode and Traffic Signal
Date:
Code: WAP for microcontroller working in timer mode and blink LED without using any loop delay
routine

#include<reg52.h>

sbit port = P1^1;

delay()
{
TMOD = 0x01;
TH0= 0xFC;
TL0 = 0x66;
TR0 = 1;
while(TF0 == 0 );
TR0 = 0;
TF0 =0;
}

main()
{
while (1)
{
port = 0x00;
delay();
port = 0xFF;
delay();
}
}

Vidyalankar School of Information Technology


Circuit Diagram: Paste the Screenshot / Picture of the Circuit

Vidyalankar School of Information Technology


Code : Write the code for Traffic Signal working in Two way direction

#include<reg52.h>
#define ON 0
#define OFF 1

sbit NG = P3^2;
sbit NY = P3^1;
sbit NR = P3^0;

sbit EG = P3^3;
sbit EY = P3^4;
sbit ER = P3^5;

sbit SG = P2^2;
sbit SY = P2^1;
sbit SR = P2^0;

sbit WG = P2^3;
sbit WY = P2^4;
sbit WR1 = P2^5;

delay(unsigned int y)
{
unsigned int i, j;

for (i = 0; i <= y; i++) {


for ( j = 0; j <= 110; j++){;}
}
}

void main(){
P2=0xff;
P3=0xff;
WR1 = ON;
Vidyalankar School of Information Technology
ER = ON;
NR = ON;
SR = ON;
delay(2000);

while (1)
{
//NORTH AND SOUTH
NR = OFF;
SR = OFF;
NG = ON;
SG = ON;
delay(2000);
NG = OFF;
SG = OFF;
NY = ON;
SY = ON;
delay(2000);
NY = OFF;
SY = OFF;
NR = ON;
SR = ON;

//EAST AND WEST


ER = OFF;
WR1 = OFF;
EG = ON;
WG = ON;
delay(2000);
EG = OFF;
WG = OFF;
EY = ON;
WY = ON;
delay(2000);
EY = OFF;
WY = OFF;
ER = ON;
WR1 = ON;
}
}

Vidyalankar School of Information Technology


Circuit Diagram : Paste the Screenshot / Picture of the Output of the Circuit

Vidyalankar School of Information Technology


Vidyalankar School of Information Technology
Vidyalankar School of Information Technology

You might also like