/*单片机,用定时中断实现每隔0.2秒让接在P1口的8个小灯从左往右循环点亮。*/
#include<reg52.h>
#include <intrins.h>
#define uchar unsigned char
uchar a,b;
uchar b=1;
uchar a=0xfe;
void main()
{
EA=1;IT1=1;ET0=1;
TH0=-5000/256;
TL0=-5000%256;
TMOD=0x01;
TR0=1;
while(1)
{;}
}
void timer0(void) interrupt 1 using 1
{
TH0=-5000/256;
TL0=-5000%256;
b=b+1;
if(b==40)
{
b=0;
P1=a;
a=_crol_(a,1);
P1=a;
}
}
温馨提示:答案为网友推荐,仅供参考