#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
String pad;
const uint8_t ROWS = 4;
const uint8_t COLS = 4;
char keys[ROWS][COLS] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
uint8_t colPins[COLS] = { 5, 4, 3, 2 };
uint8_t rowPins [ROWS] = { 9, 8, 7, 6 };
Keypad myKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Keypad");
lcd.setCursor(0, 1);
lcd.print("Test");
delay(1000);
lcd.clear();
}
void loop() {
readKeypad();
lcd.setCursor(0, 0);
lcd.print(pad);
delay(100);
}
void readKeypad() {
char keypressed = myKeypad.getKey();
String konv = String(keypressed);
pad += konv;
}