Write a program to glow 8 LEDs and after 1 second all the LEDs should be turned off when switch is pressed and when no switch is pressed last 4 LEDs should glow and then first 4 LEDS should glow and it should be repeated infinitely.


#include<8051.h>
void delay(unsigned int i)
{
while(i!=0)
{
i–;
}
}
void main()
{
while(1)
{
if(P0_0==0)
{
P1=0x00;
delay(50000);
P1=0xff;
delay(50000);
}
else
{
P1=0x0f;
delay(50000);
P1=0xf0;
delay(50000);
}
}
}

Add Comment