第1个回答 推荐于2018-04-13
#include<reg51.h>
#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<x;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<<scanled;
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);
}本回答被网友采纳