Write a program to glow all LED one by one in every 1 second from top to bottom and then from bottom to top and it should be repeated infinitely.


#include<8051.h>
void delay(unsigned int i)
{
while(i!=0)
{
i–;
}
}
void main()
{
while(1)
{
P0=0x01;
delay(50000);
P0=0x02;
delay(50000);
P0=0x04;
delay(50000);
P0=0x08;
delay(50000);
P0=0x10;
delay(50000);
P0=0x20;
delay(50000);
P0=0x40;
delay(50000);
P0=0x80;
delay(50000);
P0=0x40;
delay(50000);
P0=0x20;
delay(50000);
P0=0x10;
delay(50000);
P0=0x08;
delay(50000);
P0=0x04;
delay(50000);
P0=0x02;
delay(50000);
P0=0x01;
delay(50000);
}
}

Add Comment