第2个回答 2017-10-11
#include<reg51.h>
#define uchar unsigned char
sbit P13=P3^0;
sbit P14=P3^1;
uchar c,i,a=60,z;
uchar code Numcode[]={0XC0,//;0
0XF9,//;1
0XA4,//;2
0XB0,//;3
0X99,//;4
0X92,//;5
0X82,//;6
0XF8,//;7
0X80,//;8
0X90,//;9
};
void delay(z)
{ while(z--);
}
void main()
{TMOD=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
c=0;
i=0;
EA=1;
ET0=1;
TR0=1;
while(1)
{ if(c==20)
{ c=0;
a--;}
/*if(a>=0)
{i=a/10;
P13=1;
P0=Numcode[i];
P14=0;
delay(20);
i=a%10;
P14=1;
//i=a%10;
P0=Numcode[i];
P13=0;
delay(10);}*/
if(a>=0)
{P13=1;
i=a/10;
P0=Numcode[i];
P14=0;
delay(10);
P14=1;
i=a%10;
P0=Numcode[i];
P13=0;
delay(10);}
else
{a=60;}
}
}
void timer0() interrupt 1
{TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
c++;
}