Write a program to glow 8 LEDs and after 1 second all the LEDs should be turned off

Write a program to glow 8 LEDs and after 1 second all the LEDs should be turned off when 1st switch is pressed,when 2nd switch is pressed alternate LEDs should glow simultaneously and when no switch is pressed first 4 LEDs should glow and then last 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=0xff;
delay(50000);
P1=0x00;
delay(50000);
}
else
{
P1=0x0f;
delay(50000);
P1=0xf0;
delay(50000);
}
if(P0_1==0)
{
P1=0xaa;
delay(50000);
P1=0x55;
delay(50000);
}
}
}

Add Comment