#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar aa,count,flag;
void main() //主函数
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
aa=0xfe; //赋初值11111110
while(1) //大循环
{
P1=aa;
if(flag==1) //延时500毫秒
{
aa=_crol_(aa,1);//将aa循环左移1位后再赋给aa
flag=0;
}
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
count=0;
flag=1;
}
}