#include <Keypad.h>
const byte Rows=4;
const byte Cols=4;
char hexaKeys[Rows][Cols]={
{'1','2','3','A'},{'4','5','6','B'},
{'7','8','9','C'},{'*','0','#','D'}
};
byte rowpins[Rows]={9,8,7,6};
byte colspins[Cols]={5,4,3,2};
Keypad customKeypad=Keypad(makeKeymap(hexaKeys),rowpins,colspins,Rows,Cols);
char customkey;
void setup() {
Serial.begin(9600);
}
void loop() {
customkey=customKeypad.getKey();
if(customkey!=NO_KEY)
Serial.println(customkey);
}