I have a 4*4 membrane matrix keypad from iteadstudio:
The connector is on the bottom of the keypad. The left 4 are rows and the right 4 are columns. The columns are 0-3 from left to right so are the rows.
I wrote some code to sense this pad. But I'm interested in making the code work on as many keypads as possible. On the other hand I don't have other keypads like these:
I think in all cases you get a pin per row, and a pin per column. If not documented, you do some buzzing with a meter and see what's what.
The bottom one looks like a velleman 4x4 keypad, I might have documentation for that, and possibly even a new one in the package. Will take me a while to dig thru several boxes to find ... - hang, on its documented in my RF remte schematic.
Then use the keypad.h library and set up the code like this to interface with them:
// set up the Keypad
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
// Define the Keymap
char keys[ROWS][COLS] =
{
{ '1','2','3','A' } , // row 1
{ '4','5','6','B' } , // row 2
{ '7','8','9','C' } , // row 3
{ '*','0','#','D' } , // row 4
};
// Connect keypad ROW1, ROW2, ROW3 and ROW4 to these Arduino pins.
byte rowPins[ROWS] = { 6, 5, 4, 3 }; // Keypad uses internal pullups? No externals supplied
// Connect keypad COL1, COL2, COL3, COL4 to these Arduino pins.
byte colPins[COLS] = { 10, 9, 8, 7 };
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
// I read the keypad in void loop and put it in an array that virtual wire sends out for me
char key = keypad.getKey(); // reading the keypad
if(key) // same as if(key != NO_KEY)- did something change?
{
msg[0]=key; // load the array with the key character
}
"Digital OR operation?" AND actually - any 1 going low makes the interrupt line go lo.
Before going to sleep, I bring the columns low, then a Row connecting it will bring the diode low to make an interrupt for waking up, and on wakeup I write the columns back high, then let the keypad library take over to read the key that was pressed.
So it looks like 2,4,6,7 are the rows, and 1,3,5 are the columns on that one.
Could you do this: have them press each key, enter what comes out, then work backwards to find the mapping, and correct the row, column mapping in the code.
Maybe keep that in EEPROM so you could change it?
CrossRoads:
Could you do this: have them press each key, enter what comes out, then work backwards to find the mapping, and correct the row, column mapping in the code.
Maybe keep that in EEPROM so you could change it?
That is a smart way! I will display a prompt: "Press col:0row:0" and wait for input. I'm gonna do that for sure. It's fool-proof and interactive. Thanks!
Thanks Don. I later figured it out by staring at it for quite some time. Yes, your arrangement makes better sense than mine, which insists the order of pin numbers, which messes up the key arrangement as a result. I'll program this in my panel as a pre-set option. Wonder what the 4*4 keypads (black hard plastic) do with their connections. Maybe time to make a purchase and find out.
Hi, I would like to know how the code and the wiring for this kind of keypad with 10 pins would look like. And which diodes did you use in your diagramm (D1, D2, D3, D4)?
Farbod18:
Hi, I would like to know how the code and the wiring for this kind of keypad with 10 pins would look like. And which diodes did you use in your diagramm (D1, D2, D3, D4)?