#include <18f4520.h>
#include <build_in.h>
// MENU
unsigned short kp;
void main() {
TRISC = 0x00;
Lcd_Init(&PORTC);
Keypad_Init(&PORTB); // Initialize Keypad on PORTB
Lcd_Out(1, 4, "SELECTION"); // Selection
Lcd_Out(2, 4, "1");
Lcd_Out(2, 7, "2");
Lcd_Out(2, 10, "3");
Lcd_Out(2, 13, "4");
do {
kp = 0;
// Wait for key to be pressed and released
do {
kp = Keypad_Released();
Delay_ms(10);
}
while (!kp);
// Prepare value for output
Lcd_Cmd(Lcd_Clear);
switch (kp) {
case 1: lcd_out(1,1, "One"); break;
case 2: lcd_out(1,1, "Two"); break;
case 3: lcd_out(1,1, "Three"); break;
case 4: lcd_out(1,1, "Four"); break;
default: lcd_out(1,1, "Unknown");
}
} while (1);
}