CHAR keypadread()
// Find a key, wait for
// it to be released and return.
{ CHAR key = scankeypad();
if (key)
while (scankeypad() != 0)//松手检测
/* Nothing */ ;
return key;
}
CHAR scankeypad()
// Scan the keypad for a keypress.
// Return 0 for no press or the char pressed.
{ INT8 row,col,tmp;
CHAR key=0;
// Disable ADC functionality on Port A
ADCON1 = 6;
// Initialise Port for input, and PORTC for output
TRISA = PORTC = 0xFF;
TRISC = 0;