#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'},
};
byte rowPins[ROWS] = {5,4,3,2};
byte colPins[COLS] = {A3,A2,A1,A0};
char key = '2';
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
key = keypad.getKey();
delay(100);
if (key>= '0' && key <= '9') {
Serial.println(key);
} else if(key){
Serial.println("Please press a number");
}
}