#include
#include
#define uchar unsigned char
uchar led,time=0;
sbit key=P1^0;
void t0isr() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
led=_crol_(led,1);
P0=led;
time++;
if(time>=200)TR0=0;
}
main()
{
uchar keyval=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET0=1;
EA=1;
while(1)
{
if(key==0)
{
while(key==0);
keyval++;
keyval%=3;
}
switch(keyval)
{
case 0:led=0xff;P0=led;break;
case 1:TR0=1;led=0xfe;break;
case 2:TR0=0;break;
default:break;
}
}
}
按键中断控制流水灯
我可以做