#include<reg51.h>
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;
uchar kk,temp,Q,F;
void display();
void wei_xuan(uchar Y);
void delay(uint i,j)
{
for(;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
temp=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(kk==20)
{
kk=0;
temp++;
if(temp==100)
{
temp=0;
}
Q=temp/10;
F=temp%10;
}
display();
}
}
void wei_xuan(uchar Y)
{
switch(Y)
{
case(1):a=0;b=0;c=0;break;
case(2):a=1;b=0;c=0;break;
}
}
void display()
{
P0=table[F];
wei_xuan(1);
delay(1);
P0=table[Q];
wei_xuan();
delay(1);
}
void Timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
kk++;
}
|