#include<reg51.h>
unsigned int count=0;
unsigned char miao=0;
sbit S1=P1^0;
sbit S2=P1^1;
sbit S3=P1^2;
void timer_1()interrupt 3
{
TH1=256-250/1;
TL1=256-250/1;
count++;
if(count==2000)
{
count=0;
miao++;
if(miao==100) miao=0;
}
}
void disp(unsigned char i)
{
unsigned char j;
unsigned char led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
P3=0xff;
P2=led[i/10];
P3=0xfe;
for(j=0;j<100;j++);
P3=0xff;
P2=led[i%10];
P3=0xfd;
for(j=0;j<100;j++);
}
void main()
{
TMOD=0X20;
TH1=256-250/1;
TL1=256-250/1;
ET1=1;
EA=1;
TR1=0;
while(1)
{
if(S1==0)
{
while(!S1);
if(S1==1)
{TR1=1;
while(1)
{
disp(miao);
if(S2==0||S3==0)break;
}
}
}
if(S2==0)
{
while(!S2);
if(S2==1)
{TR1=0;
while(1)
{
disp(miao);
if(S1==0||S3==0)break;
}
}
}
if(S3==0&&miao!=0)
{
while(S3==0);
if(S3==1)
{TR1=0,miao=0;
while(1)
{disp(miao);
if(S1==0||S2==0)
break;
}
}
}
}
}
|