#include <Keypad.h>
class KeypadHandler {
private:
static constexpr uint8_t ROWS = 4;
static constexpr uint8_t COLS = 4;
Keypad* keypad;
public:
void init(uint8_t *rowPins, uint8_t *colPins) {
const char *keys = "123A456B789C*0#D";
keypad = new Keypad(keys, rowPins, colPins, ROWS, COLS);
}
char getKey() {
return keypad->getKey();
}
~KeypadHandler() {
delete keypad;
}
};
class SecurityManager {
};
KeypadHandler keypadHandler;
void setup() {
Serial.begin(9600);
static constexpr uint8_t colPins[] = { 5, 4, 3, 2 }; // C1, C2, C3, C4
static constexpr uint8_t rowPins[] = { 9, 8, 7, 6 }; // R1, R2, R3, R4
keypadHandler.init(rowPins, colPins);
}
void loop() {
char key = keypadHandler.getKey();
if (key == NO_KEY) {
return;
}
Serial.println(key);
}