|
#include
#define uint unsigned int
#define uchar unsigned char
uchar aa,num1,num2;
sbit key=P3^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
num1=0;
num2=0;
aa=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET0=1;
P0=table[0];
P2=table[0];
while(1)
{
if(key==0)
{
delay(5);
if(key==0)
{
TR0=1;
EA=1;
ET0=1;
}
while(!key);
delay(5);
while(!key);
}
if(key==0)
{
delay(5);
if(key==0)
{
TR0=0;
EA=0;
}
while(!key);
delay(5);
while(!key);
}
P2=table[num2];
P0=table[num1];
if(key==0)
{
delay(5);
if(key==0)
{
P0=table[0];
P2=table[0];
}
while(!key);
delay(5);
while(!key);
}
}
}
void timer0() interrupt 1
{
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
aa++;
if(aa==20)
{
aa=0;
num2++;
if(num2==10)
{
num2=0;
num1++;
}
}
P2=table[num2];
P0=table[num1];
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
|
|