Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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

mr.am

New Member
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);
	
	
}
 

Attachments

  • schemetic.jpg
    schemetic.jpg
    303.2 KB · Views: 245

Latest threads

Back
Top