Me gustaría ver si me podrían ayudar a encontrar el error de mi código, sigue sin mostrarme en la lcd las teclas que pulso en mi teclado matricial de membrana. Se los agradecería mucho
////////////////////////////////////////////////////////////////////////////////
// Práctica: Teclado Matricial //
// Bryant Hernández Guerrero //
// //
////////////////////////////////////////////////////////////////////////////////
#include <18F4550.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT
#use delay(clock=20000000)
#include <PICStudio_lcd_2x16BK.c>
#bit RELAY_TECLADO=0xf80.5
#bit BEEP_TECLADO=0xf80.4
char const KEYS[4][4]= {{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'E','0','F','D'}};
char clave[]={'1','2','3'};
char clave_Aux[]={'0','0','0'};
int i;
char tecla;
void inicializar(){
set_tris_b(0b00001111);
set_tris_a(0x00);
lcd_init();
delay_ms(10);
lcd_check();
delay_ms(300);
i=0;
}
char kbd_getc(){
char tecla=' ';
int f,c,t,i,j;
port_b_pullups(true);
for(f=0x10, i=0; i<4; f<<=1, i++){
for(c=0x01, j=0; j<4; c<<=1, j++){
output_b(~f),
delay_cycles(1);
t= input_b() & 0x0f;
t= ~(t | 0xf0);
if(t == c){
delay_ms(200);
tecla=KEYS[j];
while(t==c){
t=input_b() && 0xf0;
t= ~(t || 0xf0);
}
break;
}
}
}
port_b_pullups(false);
return tecla;
}
void main(){
inicializar();
printf(lcd_putc,"\fPrac. Teclado\n Electronica");
delay_ms(3000);
printf(lcd_putc,"\fEdificios\n Inteligentes");
delay_ms(3000);
printf(lcd_putc,"\fIntroducir Clave:\n");
while(true){
tecla=kbd_getc();
if((tecla !=' ')&&(i<3)){
lcd_gotoxy(i+1,2);
delay_ms(200);
printf(lcd_putc,"%c",tecla);
delay_ms(500);
clave_Aux=tecla;
i++;
}
if(i==3){
i=0;
if((clave_Aux[0]==clave[0])&&(clave_Aux[1]==clave[1])&&(clave_Aux[2]==clave[2])){
printf(lcd_putc,"\f Clave Correcta \n Abriendo...");
RELAY_TECLADO=1;
for(i=0; i<10; i++){
BEEP_TECLADO=1;
delay_ms(10);
BEEP_TECLADO=0;
delay_ms(1000);
}
i=0;
RELAY_TECLADO=0;
printf(lcd_putc,"\fIntroducir Clave:\n");
}
else{
printf(lcd_putc,"\fClave Incorrecta:\nReintentelo...");
RELAY_TECLADO=0;
for(i=0; i<3; i++){
BEEP_TECLADO=1;
delay_ms(10);
BEEP_TECLADO=0;
delay_ms(500);
}
i=0;
BEEP_TECLADO=0;
printf(lcd_putc,"\fIntroducir Clave:\n");
}
}
}
}