#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const byte numROWS = 4;
const byte numCOLS = 4;
char keymap [numROWS] [numCOLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins [numROWS] = {0,1,2,3};
byte colPins [numCOLS] = {4,5,6,7};
Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numROWS, numCOLS);
void setup() {
// put your setup code here, to run once:
lcd.begin(1, 2, 1);
Serial.begin(9600);
lcd.home();
}
void loop() {
// put your main code here, to run repeatedly:
char keyPressed = myKeypad.getKey();
if (keyPressed != NO_KEY) {
Serial.print(keyPressed);
lcd.print(keyPressed);
}
}