#define ledPin 5
#define butPin 25
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int state = LOW;
int sum = 0;
int light = LOW;




uint8_t umlaut[] = {
  0b00000,
  0b01010,
  0b00000,
  0b10001,
  0b10001,
  0b10011,
  0b01101,
};




void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  lcd.createChar(3, umlaut);
  lcd.setCursor(0, 1);
  lcd.print( "Knopfdr\x03\cke:");
  pinMode(ledPin, OUTPUT);
  pinMode(butPin, INPUT_PULLUP);
  Serial.println("Chip bereit!");
}

void loop() {
  if (digitalRead(butPin) == LOW) {
    state = !state;
    light = !light;

    sum++;


    lcd.setCursor(13, 1);              // Reihe 7, Zeile 1
    lcd.print(sum);                  // schreibt die Zahl an dieser Position aus
    //Serial.println(sum);
    //Serial.println(state);
    //Serial.println(light);

    if (light == LOW) {
      lcd.setCursor(2, 0);
      lcd.println("Licht aus!");

    } else {
      lcd.setCursor(2, 0);
      lcd.println("Licht an!");
    }



    digitalWrite(ledPin, state);   // LED nimmt den aktuellen Zustand an (siehe Zeile 22)
  } //while (digitalRead(butPin) == LOW); // Bounce Fixer (nicht notwendig, falls Bouncewert=0)
  delay(50);




}