#include <LiquidCrystal.h>
#include <Keypad.h>
const int rs=A1, en=A0, d4=A5, d5=A4, d6=A3, d7=A2;
LiquidCrystal lcd (rs, en, d4, d5, d6, d7);
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 }; // Pins connected to C1, C2, C3, C4
uint8_t rowPins[ROWS] = { 9, 8, 7, 6 }; // Pins connected to R1, R2, R3, R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
lcd.begin(20,4);
lcd.write("hallo");
delay(500);
lcd.clear();
lcd.setCursor(2,0);
lcd.write("A) eins");
lcd.setCursor(11,0);
lcd.write("B) zwei");
lcd.setCursor(2,1);
lcd.write("C) drei");
lcd.setCursor(11,1);
lcd.write("D) vier");
}
void loop() {
// put your main code here, to run repeatedly:
lcd.setCursor(2,4);
char key = keypad.getKey();
if (key != NO_KEY) {
lcd.write(key);
}
}