Hey all,
I didn't think I'd ever have to post a topic like this again after my first few months of using Arduino, but how wrong I was! Despite having used the Keypad library in projects before, I seem to have forgotten how to use it.
Here is my code:
#include <Keypad.h>
const int ROWS = 4; //four rows
const int COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'#','0','*'}
};
byte rowPins[ROWS] = {12, 13, 4, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 10, 11}; //connect to the column pinouts of the keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
}
void loop(){
byte key = kpd.getKey();
//Serial.println(key);
if (key != NO_KEY){
Serial.println(key);
}
}
As you can see it's pretty much identical to the example provided for the keypad library, save for the pin assignments. Trust me when I say this: I have checked and double checked my wiring and it agrees with the rows and columns pin assignments. I have the three COL pins connected to 5v through 10K pull ups.
Running the example code gives me strange results. First, no matter how many key presses I make, there is no output on the serial monitor. Second, when pressing any buttons on ROW 1 (Arduino pin 13), I can see the LED (the on-board LED connected to pin13) on my Arduino Uno board light up. Otherwise it is lit up very faintly.
I really cant understand what's going on here, even code I used successfully in the past is not working and I can not understand why. Would really appreciate it if someone could lend some advice.
Thanks,
B
EDIT: the keypad itself is functional as well, continuity testing with a multimeter is as expected.