One column's inputs not being registered
Have a weird issue that I can't seem to figure out.
Have a 4x4 keypad, using it on an STM32 board (bluepill).
R1-R4 on keypad connected to PA4-PA7 pins. C1-C4 on keypad connected to PA3-PA0 pins.
All keys on column 1 are not registered. Tried switching wires, pins, etc. Code is the example provided with the library. No changes whatsoever.
To test a hunch, I tried the following:
#include <Arduino.h>
#include <Adafruit_Keypad.h>
const byte ROWS = 4; // rows
const byte COLS = 5; // columns
char keys[ROWS][COLS] = {
{'Z','1','2','3','A'},
{'Z','4','5','6','B'},
{'Z','7','8','9','C'},
{'Z','*','0','#','D'}
};
byte rowPins[ROWS] = {PA4, PA5, PA6, PA7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {PA8, PA3, PA2, PA1, PA0}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Serial.begin(9600);
customKeypad.begin();
}
void loop() {
// put your main code here, to run repeatedly:
customKeypad.tick();
while(customKeypad.available()){
keypadEvent e = customKeypad.read();
Serial.print((char)e.bit.KEY);
if(e.bit.EVENT == KEY_JUST_PRESSED) Serial.println(" pressed");
else if(e.bit.EVENT == KEY_JUST_RELEASED) Serial.println(" released");
}
delay(10);
}
As you can see, all I've done is add an extra column on the left in the keymap and created the keypad object with 4 rows and 5 columns. PA8 is not connected to anything. This works perfectly well. Why is the input from the first column not registered at all?
Any explanation for this behavior will be appreciated.
This has always worked for me on the Mega and UNO
Code prior to setup() is as follows:
`char keys[ROWS][COLS] = { // Assign keys {'1', '2', '3', 'B', 'U'}, {'4', '5', '6', 'X', 'D'}, {'7', '8', '9', 'Y', 'V'}, {'C', '0', 'E', 'P', 'S'} }; byte rowPins[ROWS] = {7, 9, 10, 6}; //connect to the row pinouts of the keypad {R1, R2, R3, R4} byte colPins[COLS] = {12, 11, 8, 5, 4}; //connect to the column pinouts of the keypad {C1, C2, C3, C4, C5}
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); //Create keypad instance