Issue:
Utilising a 4 x 4 keypad in my project, the keys (A, B, C, D) do not print using Serial.println(). The other keys print fine.
Background:
I have built a rather long sketch (my own version of an irrigation controller). All has been going well, until i added the keypad. Up to now I have been using serial i/o from the PC for testing.
I am using the common 4x4 tactile keypad with the following code:
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the symbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{‘1’,‘2’,‘3’,‘A’},
{‘4’,‘5’,‘6’,‘B’},
{‘7’,‘8’,‘9’,‘C’},
{’*’,‘0’,’#’,‘D’}
};
byte rowPins[ROWS] = {22, 26, 30, 34}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {38, 42, 46, 50}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey){
Serial.println(customKey);
}
}
This code (by itself) when used as a sketch works as expected, printing all keys correctly. However when I add this code to my sketch, only the first 3 columns print, not the last column (A,B,C,D).
The only difference in my code is that I call the code shown here in loop() from a separate procedure. Otherwise there is no difference whatsoever.
Troubleshooting:
As I have a few keypads, I have tried them all. Same results as above.
Can anyone give me some ideas as to what to try next?
Thanks
Bob