51单片机 编写4个LED数码管同时循环显示0—9的数字 的程序。

2020-10-29 教育 642阅读
#include
#define uchar unsigned char
uchar code ledtab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};//0-9
uchar time,scanled,tiao;
uchar disdat[6]="201803";
void delay(unsigned int x)
{
unsigned int i,j;
for(i=0;i for(j=0;j<120;j++);
}
void t0isr() interrupt 1 //秒计时
{
TH0=0x3c;
TL0=0xb0;
time++;
if(time==20)
{
time=0;
tiao++;
tiao%=10;
}
}
void t1isr() interrupt 3 //显示
{
TH1=0xec;
TL1=0x78;
P2=1< P0=~ledtab[tiao];
scanled++;
scanled%=4;
}
main()
{
TMOD=0x11;
TH0=0x3c;
TL0=0xb0;
TH1=0xec;
TL1=0x78;
TR1=1;
TR0=1;
ET0=1;
ET1=1;
EA=1;
while(1);
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com