c51单片机 写一个数码管与流水灯的混合c程序 用串口连接起来

2025-04-07 18:06:26
推荐回答(2个)
回答(1):

#include
#include
#define uchar unsigned char
uchar distab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar led=0xfe,num=0,times=0,sel=0,segw=0;

void t0isr() interrupt 1
{
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
if(sel==2){P2=0xfd<times++;

if(times>200)
{
times=0;

if(sel==1){P2=0xfe;P0=led;led=_crol_(led,1);}

}

}
void uart() interrupt 4
{
if(RI)
{
RI=0;

sel=SBUF;

}

}
main()

{
TMOD=0x21;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=0xfd;
TL1=0xfd;
TR0=1;
TR1=1;
ET0=1;
ES=1;

EA=1;
while(1)
}

回答(2):

很简单啊。一个232,然后用串口接收。然后显示出来就好了。