4x4 Matrix - Columns 1 and 2 both read as column 1

Hi again, amazing Arduino community :slight_smile: After all the help I received with my LCD/Relay questions, I figured I'd reach out again to ask if anyone has any experience or can offer any assistance with another problem I'm facing.

I bought a little membrane keypad (http://www.amazon.com/gp/product/B0087ZEGUA/ref=oh_details_o07_s00_i00?ie=UTF8&psc=1) and was playing with it last night. I've attached a couple photos, one is of the setup, connected to a Duo.

So you see the layout of the actual keypad (and the connections on the back of the keypad, they're pretty straightforward). When I connect this and run the example Keypad library sketch (see below) it kind of works. When I press 1 or 2, 1 shows up. Similarly, when I press 4 or 5, 4 shows up, and when I press 7 or 8, 7 shows up. Basically, columns 1, 3, and 4 work, but column 2 reads as column 1.

The stranger thing is that occasionally, and I couldn't tell you what conditions actually prompt this, but an 8, 5, or 2 will come through when the appropriate key is pressed. I also received, in the package, two things that appear to be potentiometers (but I could be mistaken) and a diode. From all the examples I've seen, they don't use either of these, so I'm a little confused. I've googled around and haven't seen or heard of this problem before. My best guess at this point is that the keypad is defective in some way or another. Maybe the lines are crossed in the back of the keypad itself? I dunno. I tried looking up information for the keypad, but I couldn't find much for this particular make.

I'm going to post again with the code, since I'm not at the computer with the sketch on it.

2014-01-15 11.28.48.jpg

Here's the sketch:

/*  Keypadtest.pde
 *
 *  Demonstrate the simplest use of the  keypad library.
 *
 *  The first step is to connect your keypad to the
 *  Arduino  using the pin numbers listed below in
 *  rowPins[] and colPins[]. If you want to use different
 *  pins then  you  can  change  the  numbers below to
 *  match your setup.
 *
 */
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','F'},
  {'4','5','6','G'},
  {'7','8','9','H'},
  {'B','0','S','I'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 11, 10, 9, 8 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 7, 6, 5, 4 }; 

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  char key = kpd.getKey();
  if(key)  // Check for a valid key.
  {
        Serial.println(key);
  }
}

And here's some sample output of me repeatedly pressing the button 8 (bracketed comments didn't print, I added them):

7 [pressing 8. 7 is printing]
7
7
7
7
7
7 [still not working]
8 [totally confusing me]
7 [ back to not working]
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7

Hey! I resolved the issue! Rubber duck debugging, for the win.

Anyhow, I was using long male header pins to connect the keypadto the Arduino. I figured there must have been a line being crossed somewhere, and that must have been it. When I pull the pins out just a bit of the female flat cable coming from the keypad, it works like a champ.

Hope this helps someone else if they run into this issue!