Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top