#include <Keypad.h>
const uint8_t ROWS = 3;
const uint8_t COLS = 3;
char keys[ROWS][COLS] = {
{ '1', '2', '3' },
{ '4', '5', '6' },
{ '7', '8', '9' }
};
uint8_t colPins[COLS] = { 4, 3, 2 }; // Pins connected to C1, C2, C3
uint8_t rowPins[ROWS] = { 7, 6, 5 }; // Pins connected to R1, R2, R3
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key != NO_KEY) {
Serial.println(key);
}
}