#include<reg52.h>
//port0 light pins assign
sbit r0=P1^0;
sbit y0=P1^1;
sbit g0=P1^2;
//port1 light pins assign
sbit r1=P1^3;
sbit y1=P1^4;
sbit g1=P1^5;
//port2 light pins assign
sbit r2=P3^0;
sbit y2=P3^1;
sbit g2=P3^2;
//port3 ligt pins assing
sbit r3=P3^3;
sbit y3=P3^4;
sbit g3=P3^5;
//delay function
void delay(unsigned int);
//main function starting
void main()
{
//decleration
int a,b,c,d;
//initial all ports are zero
P1=P3=0;
//looping statement for continously working
while(1)
{
//only visible port0& port1 red led...other led are off stage
r0=1;
r1=1;
r2=0;
r3=0;
y0=0;
y1=0;
y2=0;
y3=0;
g0=0;
g1=0;
g2=1;
g3=1;
//starting a count
for(a=0;a<=55;a++)
{
r0=1;
r1=1;
g2=1;
g3=1;
delay(50);
}
// only visible port0& port1 yellow led...other led are off stage
r0=0;
r1=0;
r2=0;
r3=0;
y0=1;
y1=1;
y2=0;
y3=0;
g0=0;
g1=0;
g2=1;
g3=1;
//starting a count
for(b=0;b<=5;b++)
{
y0=1;
y1=1;
g2=1;
g3=1;
delay(50);
}
//only visible port0& port1 green led...other led are off stage
r0=0;
r1=0;
r2=1;
r3=1;
y0=0;
y1=0;
y2=0;
y3=0;
g0=1;
g1=1;
g2=0;
g3=0;
//starting a count
for(c=0;c<=55;c++)
{
g0=1;
g1=1;
r2=1;
r3=1;
delay(50);
}
//only visible port2 & port3 red led...other led are off stage
r0=0;
r1=0;
r2=0;
r3=0;
y0=0;
y1=0;
y2=1;
y3=1;
g0=1;
g1=1;
g2=0;
g3=0;
//starting a count
for(d=0;d<=5;d++)
{
y2=1;
y3=1;
g0=1;
g1=1;
delay(50);
}
}//while loop ending
}// main function ending
//delay function subprogram
void delay(unsigned int item)
{
unsigned int i,j;
for(i=0;i<=item;i++)
for(j=0;j<=1275;j++);
}
//port0 light pins assign
sbit r0=P1^0;
sbit y0=P1^1;
sbit g0=P1^2;
//port1 light pins assign
sbit r1=P1^3;
sbit y1=P1^4;
sbit g1=P1^5;
//port2 light pins assign
sbit r2=P3^0;
sbit y2=P3^1;
sbit g2=P3^2;
//port3 ligt pins assing
sbit r3=P3^3;
sbit y3=P3^4;
sbit g3=P3^5;
//delay function
void delay(unsigned int);
//main function starting
void main()
{
//decleration
int a,b,c,d;
//initial all ports are zero
P1=P3=0;
//looping statement for continously working
while(1)
{
//only visible port0& port1 red led...other led are off stage
r0=1;
r1=1;
r2=0;
r3=0;
y0=0;
y1=0;
y2=0;
y3=0;
g0=0;
g1=0;
g2=1;
g3=1;
//starting a count
for(a=0;a<=55;a++)
{
r0=1;
r1=1;
g2=1;
g3=1;
delay(50);
}
// only visible port0& port1 yellow led...other led are off stage
r0=0;
r1=0;
r2=0;
r3=0;
y0=1;
y1=1;
y2=0;
y3=0;
g0=0;
g1=0;
g2=1;
g3=1;
//starting a count
for(b=0;b<=5;b++)
{
y0=1;
y1=1;
g2=1;
g3=1;
delay(50);
}
//only visible port0& port1 green led...other led are off stage
r0=0;
r1=0;
r2=1;
r3=1;
y0=0;
y1=0;
y2=0;
y3=0;
g0=1;
g1=1;
g2=0;
g3=0;
//starting a count
for(c=0;c<=55;c++)
{
g0=1;
g1=1;
r2=1;
r3=1;
delay(50);
}
//only visible port2 & port3 red led...other led are off stage
r0=0;
r1=0;
r2=0;
r3=0;
y0=0;
y1=0;
y2=1;
y3=1;
g0=1;
g1=1;
g2=0;
g3=0;
//starting a count
for(d=0;d<=5;d++)
{
y2=1;
y3=1;
g0=1;
g1=1;
delay(50);
}
}//while loop ending
}// main function ending
//delay function subprogram
void delay(unsigned int item)
{
unsigned int i,j;
for(i=0;i<=item;i++)
for(j=0;j<=1275;j++);
}
No comments:
Post a Comment