"Getkey.c" by Engr Rashid Malik
If you want to use key pad in your project then copy this "getkey.c" file and paste at that place where you did codding in CCS Compiler or pic compiler then you can use key pad.
#define row1 PIN_C2
#define row2 PIN_C3
#define row3 PIN_D0
#define row4 PIN_D1
#define col1 PIN_D2
#define col2 PIN_D3
#define col3 PIN_C4
#define col4 PIN_C5
int8 getkey(void)
{
int8 val=100;
output_low(row1);output_high(row2);output_high(row3);output_high(row4);
// output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=1;
if(!input(col2))val=2;
if(!input(col3))val=3;
if(!input(col4))val=13;
//if(!input(col9))val=17;
output_high(row1);output_low(row2);output_high(row3);output_high(row4);
//output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=4;
if(!input(col2))val=5;
if(!input(col3))val=6;
if(!input(col4))val=14;
//if(!input(col9))val=18;
output_high(row1);output_high(row2);output_low(row3);output_high(row4);
//output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=7;
if(!input(col2))val=8;
if(!input(col3))val=9;
if(!input(col4))val=15;
//if(!input(col9))val=19;
output_high(row1);output_high(row2);output_high(row3);output_low(row4);
//output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=11;
if(!input(col2))val=0;
if(!input(col3))val=12;
if(!input(col4))val=16;
//if(!input(col9))val=20;
if(val==100)return 255;
else return val;
}
//===========
If you want to use key pad in your project then copy this "getkey.c" file and paste at that place where you did codding in CCS Compiler or pic compiler then you can use key pad.
#define row1 PIN_C2
#define row2 PIN_C3
#define row3 PIN_D0
#define row4 PIN_D1
#define col1 PIN_D2
#define col2 PIN_D3
#define col3 PIN_C4
#define col4 PIN_C5
int8 getkey(void)
{
int8 val=100;
output_low(row1);output_high(row2);output_high(row3);output_high(row4);
// output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=1;
if(!input(col2))val=2;
if(!input(col3))val=3;
if(!input(col4))val=13;
//if(!input(col9))val=17;
output_high(row1);output_low(row2);output_high(row3);output_high(row4);
//output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=4;
if(!input(col2))val=5;
if(!input(col3))val=6;
if(!input(col4))val=14;
//if(!input(col9))val=18;
output_high(row1);output_high(row2);output_low(row3);output_high(row4);
//output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=7;
if(!input(col2))val=8;
if(!input(col3))val=9;
if(!input(col4))val=15;
//if(!input(col9))val=19;
output_high(row1);output_high(row2);output_high(row3);output_low(row4);
//output_high(row5);output_high(row6);output_high(row7);output_high(row8);
if(!input(col1))val=11;
if(!input(col2))val=0;
if(!input(col3))val=12;
if(!input(col4))val=16;
//if(!input(col9))val=20;
if(val==100)return 255;
else return val;
}
//===========
No comments:
Post a Comment