firmware wip - led turn on timer works
This commit is contained in:
parent
3f5fefb557
commit
3753dfcd96
1 changed files with 29 additions and 1 deletions
|
@ -988,9 +988,37 @@ void setup() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void loop() {
|
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();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue