#include <Keypad.h>
const byte rows = 4; //four rows
const byte cols = 4; //three columns
char keys[rows][cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[rows] = {9,8,7,6}; //connect to the row pinouts of the keypad
byte colPins[cols] = {5,4,3,2}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
String intendedKeyCode = "";
int num = 0;
char key;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcdh(0x27,16,2);
void setup() {
lcdh.init();
lcdh.backlight();
lcdh.clear();
lcdh.setCursor(0,0);
lcdh.print("Please enter key");
pinMode(12, OUTPUT);
}
void loop() {
key = keypad.getKey();
if(key != NO_KEY)
{
lcdh.setCursor(8,1);
lcdh.print( key);
if(key=='B')
digitalWrite(12, HIGH);
else
digitalWrite(12, LOW);
}}