Sbit key1=P3 ^ 2;
Sbit key2=P3 ^ 3;
Sbit key3=P3 ^ 4;
Sbit key4=P3 ^ 5;
Unsigned char code seg []={xa4 xc0 0, 0 xf9, 0, 0 xb0, 0 x99, 0 x92, 0 x82,
0 xf8, 0 x80, 0 x90};//Yang digital tube 0.1.2.3.4... 9
Unsigned char code segg []={x79 0 x40, 0, 0 x24, 0 x30, 0 x19, 0 x12, 0 x02,
X78 0, 0 x00 to 0 x10};//Yang digital duct tape point 0.1.2.3.4... 9
Unsigned char intnum, the SEC;
Void delay_ms (unsigned int);//delay function
Void the display ();//display function
Void keyscan ();//key judgment function
Void init_t0 ();//timer initialization
Void main ()
{
The SEC=0;
Init_t0 ();//timer initialization
While (1)
{
The display ();
Keyscan ();
}
}
/* * * * * * * * * * * * * * line * * * * * * * * * * * * * * * * * */
Void delay_ms (unsigned int t)
{
Unsigned int x, y;
For (x=t; x> 0; X -)
{
For (y=110; Y> 0; Y -);
}
}//delay function
/* * * * * * * * * * * * * * line * * * * * * * * * * * * * * * * * */
Void the display ()
{
Unsigned qian, bai, shi ge;
Qian=the SEC/10;//one thousand
Bai=10 SEC %;//one hundred
Shi=intnum/10;//10
Ge intnum=% 10;//bits
The P2 & amp;=0 xf7;
P0=seg (ge),
Delay_ms (3);
The P2 |=0 x0f;
Delay_ms (1);//percentile value assignment
The P2 & amp;=0 XFB;
P0=seg (shi);
Delay_ms (3);
The P2 |=0 x0f;
Delay_ms (1);//is an assignment
The P2 & amp;=0 XFD;
P0=segg (bai);
Delay_ms (3);
The P2 |=0 x0f;
Delay_ms (1);//bits assignment
The P2 & amp;=0 xfe;
P0=seg [qian];
Delay_ms (3);
The P2 |=0 x0f;
Delay_ms (1);//10 assignment
}
/* * * * * * * * * * * * * * line * * * * * * * * * * * * * * * * * */
Void init_t0 ()
{
TMOD=0 x01;//adjust the timer works
TH0=0 x0d8;//initial
TL0=0 x0f0;
EA=1;
ET0=1;
TR0=0;
}
/* * * * * * * * * * * * * * line * * * * * * * * * * * * * * * * * */
Void keyscan ()
{
If (key1==0)
{
delay_ms(10);
If (key1==0)
{
TR0=1;//open timer
}
}
If (key2==0)
{
delay_ms(10);
If (key2==0)
{
TR0=0;//off timer
}
}
If (key3==0)
{
delay_ms(10);
If (key3==0)
{
TR0=1;//open timer
The SEC=0;//SEC reset
Intnum=0;//the number of seconds to reset
}
}
If (key4==0)
{
delay_ms(10);
If (key4==0)
{
TR0=1;//open timer
The SEC=0;//SEC reset
Intnum=0;//the number of seconds to reset
}
}
}
/* * * * * * * * * * * * * * line * * * * * * * * * * * * * * * * * */
Void interrupt_t0 () interrupt 1
{
TH0=0 x0d8;//initial
TL0=0 x0f0;
Intnum++;
If (intnum>
=100){
Intnum=0;
Sec++;
}
If (sec>
=100){
The SEC=0;
}
}
CodePudding user response:
The problem is?CodePudding user response:
To join https://blog.csdn.net/xianfajushi/article/details/89448933CodePudding user response:
What is the meaning of this, I don't understand what you saidCodePudding user response: