// Importing
#include <Keypad.h>
// Global Variables
const uint8_t r = 4;
const uint8_t c = r;
char keys[r][c] = {
{"1", "2", "3", "A"},
{"4", "5", "6", "B"},
{"7", "8", "9", "C"},
{"*", "0", "#", "D"}
}
uint8_t rows[r] = {5, 4, 3, 2};
uint8_t cols[c] = {9, 8, 7, 6};
// Defining the keypad
Keypad pad = Keypad(makeKeymap(keys), rows, cols, r, c)
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
};
void loop() {
// put your main code here, to run repeatedly:
char key = pad.getKey();
if (key) {
Serial.print("Key: ");
Serial.print(key);
Serial.print(" has been pressed");
Serial.println();
}
};