// ---------------------------------------------------------
// I2C - LCD Anzeige
// Pinning: ESP32 D22 <=> SCL I2C_LCD
// D21 <=> SDA
// 3V3 <=> Vcc
// GND <=> GND
// Befehle:
// oLCD.init ()
// oLCD.backlight ();
// oLCD.clear ();
// oLCD.setCursor (iSpalte,iZeile);
// oLCD.printf ("Hallo");
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 16
#define LCD_LINES 2
int Pin_buttons[4];
LiquidCrystal_I2C oLCD (I2C_ADDR, LCD_COLUMNS, LCD_LINES);
// ---------------------------------------------------------
void setup()
{
Pin_buttons[0] = 14; //nach oben
Pin_buttons[1] = 13; //nach unten
Pin_buttons[2] = 12; //nach rechts
Pin_buttons[3] = 26; //nach links
pinMode(Pin_buttons[0], INPUT_PULLUP);
pinMode(Pin_buttons[1], INPUT_PULLUP);
pinMode(Pin_buttons[2], INPUT_PULLUP);
pinMode(Pin_buttons[3], INPUT_PULLUP);
oLCD.init();
oLCD.backlight();
oLCD.setCursor (5, 1);
oLCD.printf ("Test");
}
void button_functions()
{
int iZeile;
int iSpalte;
if (digitalRead(Pin_buttons[0]) == 0)
{
oLCD.clear();
iZeile = iZeile - 1;
oLCD.setCursor(iSpalte, iZeile);
oLCD.printf ("Test");
}
else if (digitalRead(Pin_buttons[1]) == 0)
{
oLCD.clear();
iZeile = iZeile - 1;
oLCD.setCursor(iSpalte, iZeile);
oLCD.printf ("Test");
}
else if (digitalRead(Pin_buttons[2]) == 0)
{
oLCD.clear();
iSpalte -= 1;
oLCD.setCursor(iSpalte, iZeile);
oLCD.printf ("Test");
}
else if (digitalRead(Pin_buttons[3]) == 0)
{
oLCD.clear();
iSpalte += 1;
oLCD.setCursor(iSpalte, iZeile);
oLCD.printf ("Test");
}
}
void loop()
{
button_functions();
delay(10);
}