ISSUES WITH THE KEYPAD LIBRARY

I'm working on a small project with a keypad that I am trying to interface with the Keypad.h library. Everything is working fine, but when I push the A, B, C, or D button it gives me the characters from the first column instead of the 4th. I'm not sure what's going wrong in my code. Does someone have any ideas?

#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Password.h>
#include <EEPROM.h>

// Define pins used for the LCD.
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

// Define keypad parameters.
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {10, 11, 12, 13};
byte colPins[COLS] = {6, 7, 8, 9};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);



void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.clear();

}

void loop() {

  char key = keypad.getKey();

  if (key) {
    Serial.println(key);
  }


  
}

What do you get when you press keys in the first column ?

I'm not sure what's going wrong in my code. Does someone have any ideas?

Nothing. You have the keypad connected incorrectly.

(deleted)

What do you get when you press keys in the first column ?

When the first column (1, 4, 7, *) is pressed it gives the correct characters. Same with the second and third column. When the 4th column is pressed it gives the characters as if it were the 1st column.

I took the keypad out to test the row and column wires by shorting them (like the keypad would) and they all work properly. Except pin 9 seems to be a duplicate of pin 6.

jamescb82:
I took the keypad out to test the row and column wires by shorting them (like the keypad would) and they all work properly. Except pin 9 seems to be a duplicate of pin 6.

Very strange. Have you checked to see if 9 and 6 are shorted together? The sketch looks fine so I think it is a hardware problem.

Very strange. Have you checked to see if 9 and 6 are shorted together? The sketch looks fine so I think it is a hardware problem.

It really is weird. I moved the pin 9 wire around to tidy a few things up and made sure nothing was shorting, I even checked with a multimeter. Still a no go.

So I made column 4 use pin 2 instead of pin 9. That seems to have solved the problem, though I have no idea why which is really going to bother me :confused: