#include <reg52.H>
#define unchar unsigned char
#define uint unsigned int
void zz();
void delay(uint z);
void dep(unchar a,unchar b,unchar c,unchar d,unchar bai,unchar f,unchar shi,unchar ge );
unchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,
0x76,0x38,0x40};
unchar ge,shi,bai,qian,wan,baiwan;
uint t1,sec,min,hour;
void main()
{ zz();t1=0;
while(1)
{
ge=sec%10;
shi=sec/10;
bai=min%10;
qian=min/10;
wan=hour%10;
baiwan=hour/10;
dep(baiwan,wan,18,qian,bai,18 ,shi,ge);
}
}
void dep(unchar a,unchar b,unchar c,unchar d,unchar bai,unchar f,unchar shi,unchar ge)
{
P2=0xfe;
P0=table[a];
delay(10);
P2=0xfd;
P0=table[b];
delay(10);
P2=0xfb;
P0=table[c];
delay(10);
P2=0xf7;
P0=table[d];
delay(10);
P2=0xef;
P0=table[bai];
delay(10);
P2=0xDF;
P0=table[f];
delay(10);
P2=0XbF;
P0=table[shi];
delay(10);
P2=0x7f;
P0=table[ge];
delay(10);
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=10;y>0;y--);
}
void zz()
{
TMOD=0x10;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
EA=1;
ET1=1;
TR1=1;
}
void yy() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
t1++;
if(t1%20==0)
{
sec++;
if(sec>60)
{ sec=0;
min++;
if(min>60)
{ min=0;
hour++;
if(hour>24)
{
hour=0;
}
}
}
}
}
慕田峪7331174
相关分类