khatus
Member level 3
khatus post_id=311224 time=1626793245 user_id=48839 said:Hello guys I am trying to read value through key pad4*4.
This code works. But I am receiving the following error while simulating in proteus.
Code:/******************************************************************************* Program for, LCD Keypad Interfacing MCU: PIC18F4550; X-Tal: 8MHz(internal); Compiler: mikroC pro for PIC v7.6.0 Date: 19-08-2021; *******************************************************************************/ sbit LCD_RS at LATB4_bit; sbit LCD_EN at LATB5_bit; sbit LCD_D4 at LATB0_bit; sbit LCD_D5 at LATB1_bit; sbit LCD_D6 at LATB2_bit; sbit LCD_D7 at LATB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // global variables char keypadPort at PORTD; // required by 4x4 keypad library char text[17]; char ascii_to_int( char); void main() { char pulsador = 0; char valor; ADCON1=0b1111; TRISB = 0x00; TRISC = 0x00; Keypad_Init(); LCD_Init(); // Inicializamos la pantalla LCD LCD_Cmd(_LCD_CLEAR); // Limpia la pantalla LCD LCD_Cmd(_LCD_CURSOR_OFF); // Apaga el cursor en la pantalla Delay_ms(500); // Retardo de 500 milisegundos do { pulsador = Keypad_Key_Press(); valor = ascii_to_int(pulsador); //ByteToStr(pulsador, text); //Lcd_Out(1, 1, "ASCII:"); //Lcd_Out_Cp(text); Lcd_Out(1, 1, "Key: "); Lcd_Chr(1, 6, valor); } while (1); } char ascii_to_int(char pulsador) { switch (pulsador) { case 1: pulsador = 55; return pulsador; break; // 7 case 2: pulsador = 56; return pulsador; break; // 8 case 3: pulsador = 57; return pulsador; break; // 9 case 4: pulsador = 47; return pulsador; break; // / case 5: pulsador = 52; return pulsador; break; // 4 case 6: pulsador = 53; return pulsador; break; // 5 case 7: pulsador = 54; return pulsador; break; // 6 case 8: pulsador = 42; return pulsador; break; // * case 9: pulsador = 49; return pulsador; break; // 1 case 10: pulsador = 50; return pulsador; break; // 2 case 11: pulsador = 51; return pulsador; break; // 3 case 12: pulsador = 45; return pulsador; break; // - case 13: pulsador = 67; return pulsador; break; // c/on case 14: pulsador = 48; return pulsador; break; // 0 case 15: pulsador = 61; return pulsador; break; // = case 16: pulsador = 43; return pulsador; break; // + } }
Here is my schematic in proteus