firmware wip - led turn on timer works

This commit is contained in:
Marcus 2024-04-18 03:09:16 +02:00
parent 3f5fefb557
commit 3753dfcd96

View file

@ -988,9 +988,37 @@ void setup() {
*
*/
void loop() {
//Serial.println("yolo");
// var definition
unsigned int secondsSunrise = (SunriseHour * 60 * 60) + (SunriseMinute * 60);
unsigned int secondsToday = (timeClient.getHours() * 60 * 60) + (timeClient.getMinutes() * 60) + timeClient.getSeconds();
unsigned long currentRuntime = millis();
// first we call webserver handle client
webserver.handleClient();
// do every second
if(currentRuntime - outputPrevTime >= 1000) {
// debug output
Serial.print("secondsSunrise: ");
Serial.println(secondsSunrise);
Serial.print("secondsToday: ");
Serial.println(secondsToday);
//Serial.println("yolo");
// check if secondsToday is larger then secondsSunrise time
if(secondsToday >= secondsSunrise) {
// turn on light
analogWrite(PINled, PINled_PWM);
} else {
// turn off
digitalWrite(PINled, LOW);
}
outputPrevTime = currentRuntime;
}
//delay(1000);
}
/*