#include<reg51.h>
#define uchar unsigned char
sbit KEY=P3^2;
uchar LED=0xfe;
void delay(uchar a)
{
uchar i,j;
for(i=0;i<a;i++)
for(j=0;j<120;j++);
}
void ext0() interrupt 0
{
while(!KEY)
{
P0=led;
led=(led<<1)|0x01;
if(led==0xff)led=0xfe;
delay(50);
}
}
main()
{
EX0=1;
EA=1;
IT0=0;
while(1)
{
P0=0x00;
delay(100);
P0=0xff;
delay(100);
}
}
温馨提示:答案为网友推荐,仅供参考