# define uchar unsigned char
Uchar code table []={xa4 xc0 0, 0 xf9, 0, 0 xb0, 0 x99, 0 x92, 0 x82, 0 xf8, 0 x80, 0 x90};
Uchar code table_d []={xa4 xc0 0, 0 xf9, 0, 0 xb0, 0 x99, 0 x92, 0 x82, 0 xf8, 0 x80, 0 x90};
Uchar time [4]=,1,0,0 {0};
Uchar cp=0;
Sbit en=P2 ^ 5;
Void Delay (int m);
Void timer0_initialize (void);
Void the display (uchar * p);
Void main (void)
{
Uchar I, dpldata [4];
Timer0_initialize ();
En=1;
While (1)
{
for(i=0; i<4. I++)
{
If (I==1)
{
Dpldata [I]=table_d [time] [I];
}
The else
{
Dpldata [I]=table [time] [I];
}
The display (dpldata);
}
}
}
Void timer0_initialize (void)
{
EA=0;
TMOD=0 x01;
TR0=0;
TL0=0 x00;
TH0=0 xee;
PT0=0;
ET0=1;
EA=1;
TR0=1;
}
Void timer0_isr () interrupt 1
{
TR0=0;
Cp++;
If (cp==200)
{
Cp=0;
If ((time [3]==0) & amp; & (time [2] | | time [1] | | time [0] | | 0))
{
Time [3]=9;
If ((time [2]==0) & amp; & (time [1] | | time [0] | | 0))
{
Time [2]=5;
If ((time [1]==0) & amp; & (time [0] | | 0))
{
Time [1]=9;
Time [0] -;
}
The else
{
Time [1] -;
}
}
The else
{
Time [2] -;
}
}
Else if (time [3].=0)
{
Time [3] -;
}
}
Timer0_initialize ();
}
Void the display (uchar * p)
{
Int I, j=0 xfe;
for(i=0; i<4. I++)
{
The P2=j;
P0=* p;
Delay (500);
J=(j<1) | 0 x01;
If (j==0 xef)
J=0 xfe;
P++;
}
}
Void Delay (int m)
{
While (- m);
}
CodePudding user response:
https://blog.csdn.net/xianfajushi/article/details/89448933CodePudding user response: