#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit dul=P2^6;
sbit wel=P2^7;
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uchar ms);
void display(uchar shi,uchar ge);
uchar num,shi,ge;
void main()
{
TMOD=0x01;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
EA=1;
ET0=1;
TR0=0;
while(1)
{
P1=0xff;
delay(1000);
P1=0x00;
delay(1000);
shi=num/10;
ge=num%10;
dul=1;
P0=table[shi];
dul=0;
P0=0xff;
wel=1;
P0=0xfd;
wel=0;
delay(100);
dul=1;
P0=table[ge];
dul=0;
P0=0xff;
wel=1;
P0=0xfe;
wel=0;
delay(100);
}
}
void delay(uchar ms)
{
uchar i,j;
for (i=ms;i>0;i--)
for (j=110;j>0;j--);
}
void time1() interrupt 1
{
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
num++;
if(num==99) num=0;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>