From 75ecfdfa5724ccbfeefff9eeecb4b236b6cca1c1 Mon Sep 17 00:00:00 2001 From: igor Date: Sun, 9 Apr 2023 12:39:57 -0700 Subject: [PATCH] add more parameters on button press --- aqi.ino | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/aqi.ino b/aqi.ino index 6bfb501..e0c0bd3 100644 --- a/aqi.ino +++ b/aqi.ino @@ -6,6 +6,7 @@ SensirionI2CSen44 sen44; // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); +const int buttonPin = 6; float heatIndex(float t, float rh) { float hi = 0.0; @@ -44,6 +45,9 @@ void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); + // set up the button pin + pinMode(buttonPin, INPUT_PULLUP); + Wire.begin(); uint16_t error; @@ -104,21 +108,39 @@ void loop() { lcd.clear(); - lcd.setCursor(0, 0); - lcd.print("t:"); - lcd.print(round(ambientTemperature)); + if (digitalRead(buttonPin) == LOW) { + lcd.setCursor(0, 0); + lcd.print("1:"); + lcd.print(massConcentrationPm1p0); - lcd.setCursor(8, 0); - lcd.print("h:"); - lcd.print(round(ambientHumidity)); + lcd.setCursor(8, 0); + lcd.print("2:"); + lcd.print(massConcentrationPm2p5); - lcd.setCursor(0, 1); - lcd.print("f:"); - lcd.print(round(feelsLikeTemperature)); + lcd.setCursor(0, 1); + lcd.print("4:"); + lcd.print(massConcentrationPm4p0); - lcd.setCursor(8, 1); - lcd.print("v:"); - lcd.print(vocIndex, 0); + lcd.setCursor(8, 1); + lcd.print("10:"); + lcd.print(massConcentrationPm10p0); + } else { + lcd.setCursor(0, 0); + lcd.print("t:"); + lcd.print(round(ambientTemperature)); + + lcd.setCursor(8, 0); + lcd.print("h:"); + lcd.print(round(ambientHumidity)); + + lcd.setCursor(0, 1); + lcd.print("f:"); + lcd.print(round(feelsLikeTemperature)); + + lcd.setCursor(8, 1); + lcd.print("v:"); + lcd.print(vocIndex, 0); + } //Serial.println("------------"); //Serial.print("Voc:");