#include <Keypad.h>
// Character to hold key input
char customKey;
// Constants for row and column sizes
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'}
};
// *************** key board harware Connections to Arduino mega
byte rowPins[ROWS] = {31, 33, 35, 37};
byte colPins[COLS] = {23,25,27,29};
// Create keypad object
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); // to see in serial monitor dont use this Serial.begin if pin 0,1 is used for high or low, in this project it is used
}
void loop() {
customKey = customKeypad.getKey(); // should be looped here else will not wait
if (customKey) {
Serial.println(customKey);
}
}