int main()
{
//Row of Keypad
//output port for 5v as input to keypad port f
volatile char *dir_port_f , *output_f;
dir_port_f = 0x30;
*dir_port_f = 0x0f;
output_f = 0x31;
*output_f = 0x0f;
//column of Keypad
//input port to read keypad portk
volatile char *dir_k , *input_k , x ;
dir_k = 0x107;
*dir_k =0x00;
input_k = 0x106;
volatile long t;
//LED debugging column
//to debug input to keypad porta
volatile char *dir_port_a , *output_a;
dir_port_a = 0x21;
*dir_port_a = 0x0f;
output_a = 0x22;
//*output_a = 0x0f;
//LED debugging ROW
//to debug input to keypad porta
volatile char *dir_port_c , *output_c;
dir_port_c = 0x27;
*dir_port_c = 0x0f;
output_c = 0x28;
//*output_a = 0x0f;
while(1)
{
x = *input_k;
//for(t = 0 ; t <=20000; t++); //Debounce
if((x & 0x01) == 0x01)
{
//for(t = 0 ; t<= 200000; t++); //Debounce
*output_a = 0x01;
*output_c = 0x01;
}
if((x & 0x02) == 0x02)
{
//for(t = 0 ; t<= 200000; t++); //Debounce
*output_a = 0x02;
*output_c = 0x01;
}
if((x & 0x04) == 0x04)
{
//for(t = 0 ; t<= 200000; t++); //Debounce
*output_a = 0x04;
*output_c = 0x01;
}
if((x & 0x08) == 0x08)
{
//for(t = 0 ; t<= 200000; t++); //Debounce
*output_a = 0x08;
*output_c = 0x01;
}
else
*output_a = 0x00;
}
return 0;
}