设MCS-51的单片机P1端口控制8个LED灯,要求从右向左逐个点亮,每只灯亮0.5

2024-10-28 18:28:52
推荐回答(1个)
回答1:

#include
#include
#define uchar unsigned char
uchar cnt;
void t0isr() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
cnt++;
P1=_crol_(P1,1);
}
main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
ET0=1;
EA=1;
P1=0xfe;
while(1);
}