/**********************************************
Sammt Luca
LCD Display
25.04.2024 *
2AHME *
***********************************************/
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); // LCD-Pins
const int Button_Pin = 5; // Taster-Pin
const int analogInputPin = A0;
bool measurementActive = false; // Variable für den Messstatus
unsigned long startTime = 0; // Startzeit der Messung
enum Messwert {
EIN,
AUS
};
Messwert Messwertstate = EIN;
void setup() {
pinMode(Button_Pin, INPUT_PULLUP);
lcd.begin(16, 2);
}
void loop() {
switch(Messwertstate) {
case EIN:
if (digitalRead(Button_Pin) == LOW && !measurementActive) {
measurementActive = true;
startTime = millis();
lcd.clear();
lcd.print("MESSUNG AKTIV");
}
if (measurementActive && millis() - startTime >= 500) {
startTime = millis();
int sensorValue = analogRead(analogInputPin);
lcd.setCursor(0, 1);
lcd.print("Wert: ");
lcd.print(sensorValue);
}
else Messwertstate = AUS;
break;
case AUS:
if ((digitalRead(Button_Pin) == LOW && measurementActive) || (millis() - startTime >= 10000)) {
measurementActive = false;
lcd.clear();
lcd.print("MESSUNG INAKTIV");
}
else Messwertstate = EIN;
break;
}
}