The code is simple, read key pressed and print on the terminal
On an Arduino Uno everything is ok, but when using on ESP32 thing I also get a special char on every loop.
#include <Arduino.h>
#include <Keypad.h>
// Keypad init
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {32, 33, 25, 26};
byte colPins[COLS] = {27, 14, 12, 13};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
char customKey;
// Setup
void setup()
{
Serial.begin(9600);
}
// Setup
// Loop
void loop()
{
char customKey = customKeypad.getKey();
Serial.println(customKey);
}
// Loop