我写了个流水灯程序。想用定时器来实现两个灯亮之间延时1秒。请问我的程序应该怎样修改?谢谢了!# include<reg51.h>
# include<intrins.h>
# define ui unsigned int
# define uc unsigned char
uc temp, i, j, m;
int main(void)
{
while(1)
{
TMOD = 0x11;
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;
EA = 1;
ET0 = 1;
TR0 = 1;
while(1)
{
for(i=0; i<7; i++)
{
temp = 0xfe;
P1 = temp;
temp = _crol_(temp, 1);
P1 = temp;
}
for(i=0; i<7; i++)
{
temp = 0x7f;
P1 = temp;
temp = _cror_(temp, 1);
P1 = temp;
}
}
}
return 0;
}
void
timer0() interrupt 1
{
for(i=0; i<20; i++)
{
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;
}
}
一周热门 更多>