#include <reg51.h>
typedef unsigned int u16;
typedef unsigned int u8;
sbit S0=P0^0;//定义开灯的开关
sbit S1=P0^1;//定义关灯的开关
void time(u16 i)
{
while(i--);
}
void main()
{
label:while(1)
{
u16 k;
P2=0xFF;
if(S0==0)
{
time(500);
if(S0==0)
{
while(1)
{
P2=0x80;
for(k=1;k<9;k++)
{
P2=~P2;
time(20000);
P2=~P2;
P2>>=1;
if(S1==0)
goto label;
}
}
}
}
}
}