Hello community, I come here because I'm not quite sure if I'm doing something wrong or if there is something wrong with my hardware. Here's the deal:
- I have connected as directed per tutorial a 4x4 keypad to an arduino leonardo using the following code:
#include <Keypad.h>
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'},
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 6, 8, 7, 9 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 2, 5, 4, 3 };
// 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);
}
}
It works quite ok, but some keys are not read by the Arduino when the're hit.
- Keys that don't work: 2, 3, A & 4, 7, *.
- All rest work and show accordingly
- All col OR row have at least 1 key working OK
What am i missing here?