#include<reg52.h>
unsigned char code a[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void timer();
void xianshi();
unsigned char M,shi,miao,g;
void delay(unsigned int i)
{ char j;
for(i; i > 0; i--)
for(j = 115; j> 0; j--);
}
void main ()
{
miao=0;
while(1)
{ miao++;
if(miao<60)
{
timer();
xianshi();
}
else
miao=0;
}
}
void timer()interrupt 1
{ EA=1;
TMOD = 0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET0=1;
TR0=1;
M=0;
while(M<20)
{
if(TF0==1)
{ M++;
TF0 = 0;
}
}
}
void xianshi()
{
shi=miao/10;
g=miao%10;
P2=0xfe;
P0=a[g];
delay(10);
P2=0xfd;
P0=a[shi];
delay(10);
}
|