#include <Keypad.h>
// symbols on the keypad
char keys [4][4] = {
{'1','2','3','A'},
{'5','6','7','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[4] = {11, 10, 9, 8}; // connect row pinouts of the keypad
byte columnPins[4] = {7, 6, 5, 4}; // connect column pinouts of the keypad
// initialize a class Keypad
Keypad myKeypad = Keypad(makeKeymap(keys), rowPins, columnPins, 4, 4);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // baud rate of 9600
}
void loop() {
// put your main code here, to run repeatedly:
char keyPressed = myKeypad.getKey();
// if there is character input, send it to serial port
if(keyPressed){
Serial.println(keyPressed);
}
}