From c723542be7b74f65dc30755f89f6fa8913874337 Mon Sep 17 00:00:00 2001 From: hans-jurgen Date: Sat, 26 Oct 2024 14:05:40 +0200 Subject: [PATCH] 2024-10-2600 LED-Ansteuerung --- src/main.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d472002..559bd65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,6 +16,7 @@ Updated by Bodmer for variable meter size */ #define ledGreen 16 +#define ledRed 4 /* rot */ // Define meter size as 1 for tft.rotation(0) or 1.3333 for tft.rotation(1) #define M_SIZE 1.3333 @@ -89,7 +90,6 @@ void setup(void) { updateTime = millis(); // Next update time pinMode(ledGreen, OUTPUT); - analogWrite(ledGreen, 102); //init_HTU21(); //delay(5000); } @@ -142,6 +142,24 @@ void loop() { tft.drawString("%", 270, 210, 4); } Serial.print(Temperatur,4); Serial.println(" °C"); + if ((event.relative_humidity >=65) & (event.relative_humidity<=75)){ + analogWrite(ledGreen, 255-165); + analogWrite(ledRed, 0); + //Serial.println("LEDGreen-AN"); + } + else if ((event.relative_humidity >=50) & (event.relative_humidity<=65)){ + analogWrite(ledGreen, 0); + analogWrite(ledRed, 255); + //Serial.println("LEDGreen-AN"); + } + else if (event.relative_humidity >=75){ + analogWrite(ledRed, 0); + analogWrite(ledGreen, 255); + //Serial.println("LED-RedAN"); + } else { + analogWrite(ledRed, 255); + //Serial.println("LEDRed-AUS"); + } } }