Strike_UN
Junior Member level 1
iam just doing simple keypad with pic24 but i dont know why its not working properly here is my code
no problem in build but when i try on proteus there is no o/p
and here is the circuit i drew i know the keypad is upside down but i just wanna see output -.-
Code:
sbit enter at portg.b2;
sbit LCD_RS at LATD0_bit;
sbit LCD_EN at LATD1_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 TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_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;
unsigned keypadPort at PORTE;
unsigned keypadPort_Direction at TRISE;
unsigned short kp;
unsigned char var_array[1];
unsigned char key_array[60];
unsigned int k=0;
unsigned int enter_f=0;
void main() {
Keypad_Init();
Lcd_Init();
lcd_cmd(_lcd_cursor_off);
lcd_out(1,3,"start up");
delay_ms(1000);
lcd_cmd(_lcd_clear);
while(1){
kp = Keypad_Key_click();
if(kp!=0){
switch (kp) {
case 1: kp = 49; break; // 1 // Uncomment this block for keypad4x4
case 2: kp = 50; break; // 2
case 3: kp = 51; break; // 3
case 4: kp = 65; break; // A
case 5: kp = 52; break; // 4
case 6: kp = 53; break; // 5
case 7: kp = 54; break; // 6
case 8: kp = 66; break; // B
case 9: kp = 55; break; // 7
case 10: kp = 56; break; // 8
case 11: kp = 57; break; // 9
case 12: kp = 67; break; // C
case 13: kp = 42; break; // *
case 14: kp = 48; break; // 0
case 15: kp = 35; break; // #
case 16: kp = 68; break; // D
}
var_array[0]=kp;
lcd_out(1,1,var_array);
kp=0;
}
if(enter==1&&enter_f==0){
enter_f=1;
key_array[k]=var_array[0];
lcd_out(2,1,key_array);
k++;
}
if(enter==0){
enter_f=0;
}
}
}
and here is the circuit i drew i know the keypad is upside down but i just wanna see output -.-