From: gregor herrmann Date: Sun, 1 Nov 2020 03:32:05 +0000 (+0100) Subject: move LCD output before buzzer X-Git-Url: https://git.toastfreeware.priv.at/toast/airingbutler.git/commitdiff_plain/0f9922d340f33409410c2b8cf6a8d2adf9bda1bd move LCD output before buzzer the buzzer has a delay, so let's update the LCD before making noise. --- diff --git a/airingbutler.ino b/airingbutler.ino index 92461a6..ebdc5ee 100644 --- a/airingbutler.ino +++ b/airingbutler.ino @@ -85,20 +85,12 @@ void loop() Serial.print(","); Serial.println(temp); + // LEDs digitalWrite(led_red_pin, co2 >= co2_alarm_thr); digitalWrite(led_yellow_pin, co2 >= co2_warning_thr && co2 < co2_alarm_thr); digitalWrite(led_green_pin, co2 < co2_warning_thr); - if (co2 >= co2_alarm_thr && lastppm < co2_alarm_thr && time - lastwarntime > cooldowntime) { - buzz(100, 3); - lastwarntime = time; - } - - if (co2 >= co2_warning_thr && lastppm < co2_warning_thr && time - lastwarntime > cooldowntime) { - buzz(500, 1); - lastwarntime = time; - } - + // LCD lcd.setCursor(0, 0); lcd.print("CO2: "); lcd.print(co2); @@ -111,6 +103,16 @@ void loop() lcd.print(temp); lcd.print(" C +/- "); + // buzzer + if (co2 >= co2_alarm_thr && lastppm < co2_alarm_thr && time - lastwarntime > cooldowntime) { + buzz(100, 3); + lastwarntime = time; + } + if (co2 >= co2_warning_thr && lastppm < co2_warning_thr && time - lastwarntime > cooldowntime) { + buzz(500, 1); + lastwarntime = time; + } + lastppm = co2; delay(5000); }