1#include <Keypad.h>
2
3const byte ROWS = 4;
4const byte COLS = 4;
5
6char hexaKeys[ROWS][COLS] = {
7 {'1', '2', '3', 'A'},
8 {'4', '5', '6', 'B'},
9 {'7', '8', '9', 'C'},
10 {'*', '0', '#', 'D'}
11};
12
13byte rowPins[ROWS] = {9, 8, 7, 6};
14byte colPins[COLS] = {5, 4, 3, 2};
15
16Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
17
18void setup(){
19 Serial.begin(9600);
20}
21
22void loop(){
23 char customKey = customKeypad.getKey();
24
25 if (customKey){
26 Serial.println(customKey);
27 }
28}1const byte rows = 4; //four rows
2const byte cols = 3; //three columns
3char keys[rows][cols] = {
4 {'1','2','3'},
5 {'4','5','6'},
6 {'7','8','9'},
7 {'#','0','*'}
8};
9byte rowPins[rows] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
10byte colPins[cols] = {8, 7, 6}; //connect to the column pinouts of the keypad
11Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
12