Interfacing Push-On switch as 4x1 keypad with 18F

Status
Not open for further replies.

mr.am

Newbie level 1
Joined
Feb 24, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,285
4x1 keypad

Hi.. I really don't know, how come the problem, but the push on switch never give a bit of Effect to the LCD display..

here is my schematic diagram and code..


Code:
#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);
	
	
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…