uchar code table[] = { 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88};//,0x83,0xC6,0xA1,0x86,0x8E,0xFF};
uchar code dispbit[]={0x01,0x02};//数码管位选码
uchar dis1[]={0,0};
uchar num,temp=10;
uchar t0=0;
void Delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--)
;
}
void init()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
// temp=0xfb;
// P1=temp;
}
void Display()
{
uchar i,x,y;
dis1[0]=num/10;
dis1[1]=num%10;
for(i=0;i<2;i++)
{
P0=table[dis1[i]];
P3=table[dis1[i]];
P2=dispbit[i];//位选
Delay(5);
P2=0x00;
if(key==1)
{
P1=0xf6;
EA=0;
for(x=5000;x>0;x--)
for(y=110;y>0;y--);
}
else EA=1;
}
}
void main()
{
init();
num=50;
while(num!=0)
{
loop:Display();
if(key==1)
goto loop;
P1=0xde;
// Delay(10);
if(num==5)
{
while(num!=0)
{
loop2:Display();
if(key==1)
goto loop2;
P1=0xee;
Delay(10);
// P1=0xfe;
// Delay(10);
}
}
}
num=30;
while(num!=0)
{
loop1:Display();
if(key==1)
goto loop1;
P1=0xf3;
// Delay(10);
if( num==5)
{
while(num!=0)
{
loop3:Display();
if(key==1)
goto loop3;
P1=0xfd;
Delay(3);
}
}
// P1=0xfb;
// Delay(3);
}
}
void
time0()interrupt 1 using 0
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t0++;
if(t0==20)
{
t0=0;
num--;
}
}
一周热门 更多>