#include<reg52.h>
unsigned char ledchar[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char number[]={0xff,0xff};
unsigned int cnt200;
unsigned int cnt1000;
unsigned char num=20;
void liushui()
{
num--;
number[0]=ledchar[num%10];
number[1]=ledchar[num/10%10];
if(num==0)
}
void light()
{
unsigned char j;
j++;
P2=~(0x01<<j);
if(j==8)
j=0;
}
void main()
{
TMOD=0X01;
TH0=0XFC;
TL0=0X67;
EA=1;
TR0=1;
ET0=1;
while(1)
{
if(cnt1000>=1000)
{
cnt1000=0;
liushui();
}
if(cnt200>=200)
{
cnt200=0;
light();
}
}
}
void time_0() interrupt 1
{
unsigned char j;
TH0=0XFC;
TL0=0X67;
cnt200++;
cnt1000++;
switch(j)
{
case 0:P1=0x01;P0=number[0];j++;break;
case 1:P1=0x02;P0=number[1];j=0;break;
}
}
|