Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

New Articles From Microcontroller Tips

Back
Top