# define under-16 unsigned int
# define u8 unsigned char
Under-16 count=0;
Sbit LSA=P2 ^ 2;//definition decoder 38
Sbit LSB=P2 ^ 3;
Sbit LSC=P2 ^ 4;
Sbit K1=P3 ^ 1;
Sbit K2=P3 ^ 0;
Sbit K3=P3 ^ 2;
Sbit K4=P3 ^ 3;
U8 code smgduan [10]={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f,};
U8 disp [4].
Under-16 GW=0;
Under-16 SW=0;
Under-16 BW=0;
Under-16've=0;
Void delay (under-16 j)
{
While (j);
}
Void datapros ()
{
Disp [0]=smgduan (GW),//one thousand
Disp [1]=smgduan (SW);//one hundred
Disp [2]=smgduan (BW);//10
Disp [3]=smgduan ['ve];//bits
If (K2==0)
{
ET0=~ ET0; }
}
Void Timer0 () interrupt 1
{
TH0=(65536-50000)/256;//50 ms into the timer
TL0=(65536-50000) % 256;
count++;
If (count>=20)
{
Count=0;
GW=GW + 1;
Datapros ();
}
}
Void Timer0Init ()
{
TMOD=0 x01;
TH0=(65536-50000)/256;
TL0=(65536-50000) % 256;
EA=1;
ET0=1;
TR0=1;
}
Void DigDisplay ()
{
U8 t;
For (t=0; T<=3; T++)
{
The switch (t)
{
Case (0) :
LSA=0; LSB=0; LSC=0; break;//GW
Case (1) :
LSA=1; LSB=0; LSC=0; break;//SW
Case (2) :
LSA=0; LSB=1; LSC=0; break;//BW
Case (3) :
LSA=1; LSB=1; LSC=0; break;//'ve
//GW, SW, BW,'ve constitute points
}
P0=disp [t];
Delay (100);
P0=0 x00;
}
If (GW> 9)//bits are reset and forward 1> 9
{
GW=0;
SW++;
}
If (SW>=6)//ten more than 6 seconds to reset and to divide into 1
{GW=0;
SW=0;
BW++; }
If (BW> 9)//
{QW++;
BW=0; }
If (QW>
=6){'ve=0;
BW=0; }
}
Void the start ()
{
Datapros ();
DigDisplay ();
}
Void main ()
{the while (1)
{
DigDisplay ();
While (1)
{
Timer0Init ();
If (K1==0)
{
While (1)
{
Start ().
If (K3==0)
{
GW=0;
SW=0;
BW=0;
've=0;
EA=1;
}
continue;
}
}
}
}
}
CodePudding user response:
Does not need to shake?