Go Down

Topic: About pins on a membrane matrix keypad (Read 2565 times) previous topic - next topic

liudr

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.

CrossRoads

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:
Code: [Select]

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

Code: [Select]

    // 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
   }

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

liudr

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?

CrossRoads

"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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

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?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

liudr


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!

floresta

Quote
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

liudr

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.

CrossRoads

The schematic I posted above shows the pinout for the Velleman 4x4 black plastic keypad.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

liudr


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.

CrossRoads

Yes.

Some set up code for it:
Code: [Select]


// 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 );
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

liudr


Go Up