0% found this document useful (0 votes)
17 views2 pages

Programacion de Teclado y LCD

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Programacion de Teclado y LCD

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

unsigned short kp = 0;

// Keypad module connections


char keypadPort at PORTB;
// End Keypad module connections

// LCD module connections


sbit LCD_RS at RA0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RA2_bit;
sbit LCD_D5 at RA3_bit;
sbit LCD_D6 at RA4_bit;
sbit LCD_D7 at RA5_bit;

sbit LCD_RS_Direction at TRISA0_bit;


sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISA2_bit;
sbit LCD_D5_Direction at TRISA3_bit;
sbit LCD_D6_Direction at TRISA4_bit;
sbit LCD_D7_Direction at TRISA5_bit;
// End LCD module connections

void main() {
ADCON1=0X0F;
Keypad_Init();

Lcd_Init(); // Initialize LCD


Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

Lcd_Out(1, 1, "SE INGRESO :");

do {
kp = 0; // Reset key code variable

// Wait for key to be pressed and released


do
// kp = Keypad_Key_Press(); // Store key code in kp variable
kp = Keypad_Key_Click(); // Store key code in kp variable
while (!kp);
// Prepare value for output, transform key to it's ASCII value
switch (kp) {
//case 10: kp = 42; break; // '*' // Uncomment this block for keypad4x3
//case 11: kp = 48; break; // '0'
//case 12: kp = 35; break; // '#'
//default: kp += 48;

case 1: kp = 55; break; // 1 // Uncomment this block for keypad4x4


case 2: kp = 56; break; // 2
case 3: kp = 57; break; // 3
case 4: kp = 47; break; // A
case 5: kp = 52; break; // 4
case 6: kp = 53; break; // 5
case 7: kp = 54; break; // 6
case 8: kp = 42; break; // B
case 9: kp = 49; break; // 7
case 10: kp = 50; break; // 8
case 11: kp = 51; break; // 9
case 12: kp = 45; break; // C
case 13: kp = 126; break; // *
case 14: kp = 48; break; // 0
case 15: kp = 61; break; // #
case 16: kp = 43; break; // D

}
Lcd_Chr(1,15,kp);

} while (1);
}

You might also like