Keypad
Keypad
* MCU : PIC16F887
* Xtal : 4Mhz
******************************************************************************/
//-------------------------------------------------------//
void Port_Init()
ANSEL=0;
ANSELH=0;
TRISB=0;
TRISC=0xf0;
TRISD=0;
TRISA=0;
TRISE=0;
PORTA=0;
PORTB=0;
PORTC=0xff;
PORTD=0;
PORTE=0;}
//-------------------------------------------------------//
//-------------------------------------------------------//
char scan_key()
char row=0;
for (row=0;row<4;row++)
KEY=scan_row[row];
return '\0';
}
//=======================================================//
// MAIN FUNCTION //
//=======================================================//
void main()
{ Port_Init();
PORTD=0xff;
while(1)
while(key_code!='1'&&key_code!='2'&&key_code!='3'&&key_code!='4'&&key_code!='5
'&&key_code!='*')
key_code = scan_key();
switch (key_code)