ESP32 keypad strange behavior: some kind of pin combination doesn't work.
Posted: Sun May 16, 2021 1:57 pm
I'm trying to test keypad with ESP32. the keypad is 4*4, I tried some of combination of pin setting, some of combination works but some fails.
this combination works:
byte rowPins[ROWS] = {26,25,33,32};
byte colPins[COLS] = {15,2,0,4};
this combination fails, seems pin16, pin17
byte rowPins[ROWS] = {26,25,33,32};
byte colPins[COLS] = {4,16,17,5};
could anyone know the reason why 2nd combination failed?
Code: Select all
#include <Wire.h>
#include <Keypad.h>
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] = {14, 27, 26,25};
byte colPins[COLS] = {4, 16, 17, 5,};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
Serial.begin(115200);
keypad.addEventListener(mykeypadEvent);
}
void mykeypadEvent(KeypadEvent key){
Serial.printf("in event, key: %d, state=%d\n", key,keypad.getState());
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY)
Serial.printf("key: %c pressed\n", key);
}
byte rowPins[ROWS] = {26,25,33,32};
byte colPins[COLS] = {15,2,0,4};
this combination fails, seems pin16, pin17
byte rowPins[ROWS] = {26,25,33,32};
byte colPins[COLS] = {4,16,17,5};
could anyone know the reason why 2nd combination failed?