#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 x(0x27,16,2);
void setup() {
x.init();
x.backlight();
x.clear();
pinMode(12, OUTPUT);
}
void loop() {
key = keypad.getKey();
if(key != NO_KEY)
{
x.setCursor(5,0);
x.print( key);
delay(500);
if(key=='2')
digitalWrite(12,1);
else digitalWrite(12,0);
}}