4 By 4 matrix key pad

Status
Not open for further replies.

GreenP

New Member
Hi There

Is there anyone out there who has some c code for the scanning of a 4* 4 matrix keypad?

Thanks
greenP
 
Assumes layout 0123/4567/89ab/cdef, 048c in column 3 (bit value 8), cdef in row 3(bit val 8).
Also assumes the existence of a setcol function which will send a current up a column, and a getrow function that will check for a current coming back from a row.
NB: not tested
Code:
int num=0;
int col=8,c=0;
while (col)
{
 setcol(col);
 if (getrow(1)) num=c;
 else if (getrow(2)) num=4+c;
 else if (getrow(4)) num=8+c;
 else if (getrow(8)) num=12+c;
 col/=2;c++;
}
 
Depending on connection characteristics, allow some SETTLING time before reading the rows of the grounded columns. Also, reading them with analog inputs allows an adjustable threshold for noise rejection if necessary.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…