Typedef unsigned int under-16;
Typedef unsigned char u8;
U8 KeyValue;
# define GPIO_KEY P1
Unsigned char code anjian []={" 10 "};
Unsigned char I, j;
Bit flag.
Void delay (unsigned int n)
{
Unsigned char a, b;
for(a=0; A
}
Void UsartInit ()
{
SCON=0 x50;
TMOD=0 x20;
PCON=0 x80;
TH1=0 xf3;
TL1=0 xf3;
//ES=1;
//EA=1;
TR1=1;
}
Void Send_string (unsigned char c)
{
SBUF=c;
While (TI==0);
TI=0;
}
Void the key ()
{
GPIO_KEY=0 x0f;
If (GPIO_KEY!=0 x0f)
{delay (100);
If (GPIO_KEY!=0 x0f)
{GPIO_KEY=0 x0f;
The switch (GPIO_KEY)
{
Case (0 x07) : KeyValue=https://bbs.csdn.net/topics/0; break;
Case (0 x0b) : KeyValue=https://bbs.csdn.net/topics/1; break;
Case (0 x0d) : KeyValue=https://bbs.csdn.net/topics/2; break;
Case (0 x0e) : KeyValue=https://bbs.csdn.net/topics/3; break;
}
//2 ae? DD
GPIO_KEY=0 xf0;
The switch (GPIO_KEY)
{
Case (0 x70) : KeyValue=https://bbs.csdn.net/topics/KeyValue; break;
Case (0 xb0) : KeyValue=https://bbs.csdn.net/topics/KeyValue+4; break;
Case (0 xd0) : KeyValue=https://bbs.csdn.net/topics/KeyValue+8; break;
Case (0 xe0-0xfc) : KeyValue=https://bbs.csdn.net/topics/KeyValue+12; break;
}
I=KeyValue;
Send_string (anjian [I]);
delay(10);
}
}
}
Void main (void)
{
UsartInit ();
While (1) {key (); }}
CodePudding user response:
Baud rate isn't kept at just the right, have the code that transport, try a lower baud rateCodePudding user response:
1. Check the baud rate matches the2. Check the display is the hexadecimal or characters
CodePudding user response: