#include <Keypad.h>
const char number_of_rows = 4;
const char number_of_columns = 4;
char row_pins[number_of_rows] = {9, 8, 7, 6}; // setting up the array of rows
char column_pins[number_of_columns] = {5, 4, 3, 2}; // setting up the array of columns
char key_array[number_of_rows][number_of_columns] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
Keypad k = Keypad(makeKeymap(key_array),row_pins,column_pins,number_of_rows,number_of_columns);
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_pressed = k.getKey();
if (key_pressed){
Serial.println(key_pressed);
}
}