#include <Keypad.h>
//constant for row and column size
const byte Rows=4;
const byte Cols=4;
//array to represent keys on keypad
char hexakeys [Rows][Cols]={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
//connections to arduino
byte rowpins[Rows]={9,8,7,6};
byte colpins[Cols]={5,4,3,2};
//Creating keypad object
Keypad customkeypad=Keypad(makeKeymap(hexakeys),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:
char key=customkeypad.getKey();
if(key){
Serial.println(key);
}
}