diff --git a/aqi.ino b/aqi.ino index 5e3edca..4d79b94 100644 --- a/aqi.ino +++ b/aqi.ino @@ -4,14 +4,13 @@ #include SensirionI2CSen44 sen44; -// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int buttonPin = 6; // to simulate "parallelism" unsigned long currentTime; unsigned long sen44Time = 0; -unsigned long lcdTime = 0; +unsigned long lcdTime = 0; unsigned long buttonTime = 0; // display standard values by default @@ -28,7 +27,8 @@ float ambientTemperature = 0; float feelsLikeTemperature = 0; // calculate heat index -float heatIndex(float t, float rh) { +float heatIndex(float t, float rh) +{ float hi = 0.0; if (t <= 40.0) hi = t; @@ -53,11 +53,13 @@ float heatIndex(float t, float rh) { } // convert celcius to fahrenheit -float celsiusToFahrenheit(float degrees) { +float celsiusToFahrenheit(float degrees) +{ return degrees * 1.8 + 32; } -void setup() { +void setup() +{ Serial.begin(115200); while (!Serial) delay(100); @@ -95,18 +97,15 @@ void setup() { sen44.startFanCleaning(); } -void loop() { +void loop() +{ currentTime = millis(); - delay(50); - - // Display Button - if (currentTime - buttonTime >= 100) { + if (currentTime - buttonTime >= 500) { buttonTime = currentTime; - if (digitalRead(buttonPin) == LOW) { + if (digitalRead(buttonPin) == LOW) isStandardValues = !isStandardValues; - } } // sen44 @@ -134,7 +133,7 @@ void loop() { } // Display - if (currentTime - lcdTime >= 500) { + if (currentTime - lcdTime >= 2000) { lcdTime = currentTime; lcd.clear();