//explanation keypad: https://deepbluembedded.com/esp32-keypad-lcd-example-arduino/
// https://arduinogetstarted.com/tutorials/arduino-keypad#content_about_keypad
#include "Keypad.h"
#include <LiquidCrystal_I2C.h>
//Í2C Adress and column and line defintion of de LCD
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
// create LCD-object
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
// define matrix of the keyboard
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
// define keyboard layout
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// define input ports for keyboard
byte rowPins[ROWS] = {23, 12, 3, 13};
byte colPins[COLS] = {19, 18, 5, 17};
// create keyboard-object
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(115200);
// init (start) LCD
lcd.init();
// Turn on the backlight on LCD.
lcd.backlight();
// print the Message on the LCD.
lcd.print("Keyboardeingabe:");
Serial.println("ESP32 Keyboard connection");
}
void loop() {
delay(10); // this speeds up the simulation
// get keyboard input
char key = keypad.getKey();
//output on LCD and console
if (key){
lcd.setCursor (0, 1);
lcd.print (key);
Serial.println(key);
}
}