About pins on a membrane matrix keypad

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:

and

How are the columns and rows laid out on these above pads? Thanks.

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
   }

Thanks CrossRoads. I was estimating the keypads all have the same layout until I saw this on sparkfun:

Strange way to arrange keys. I guess there is no way I can make the key map work on all keypads. The users will have to decide how to map themselves.

BTW, what is the purpose of putting diodes on the row pins? Digital OR operation?

"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!

Strange way to arrange keys.

It's an even stranger way to describe the connections. Even with an ASCII diagram I can do better than that.

pin 2 ------ 1----2----3
pin 7 ------ 4----5----6
pin 6 ------ 7----8----9
pin 4 ------ *----0----#
             |    |    |
pin 3 -------|    |    |
pin 1 ------------|    |
pin 5 -----------------|

Don

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.

The schematic I posted above shows the pinout for the Velleman 4x4 black plastic keypad.

CrossRoads:
The schematic I posted above shows the pinout for the Velleman 4x4 black plastic keypad.

So this one?

http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001__2131055_-1

Then the left 4 pins are columns and right 4 are rows? That's all I needed to know.

Yes.

Some set up code for it:

// added Keypad example from playground
// modified to send character in a buffer to the receiver from 4x4 matrix

// Velleman 4 x 4 matrix keypad 
// keypad 1 (Col1) to D10
// keypad 2 (Col2) to D9
// keypad 3 (Col3) to D8
// keypad 4 (Col4) to D7
// keypad 5 (Row1) to D6
// keypad 6 (Row2) to D5
// keypad 7 (Row3) to D4
// keypad 8 (Row4) to D3

// Rows have Internal Pullups

// 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 );

Great! Thanks!

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)?

Google: 4X4 keypad Arduino

You will have to check the keypad pins for continuity.

Use 1N914 or 1N4148 for the diodes.

Best start a new thread.

Rename to .ino

transmitter_mine_updated_Simon_Bell_DiodeOR_revisedSleep.pde (9.38 KB)