add more parameters on button press

This commit is contained in:
2023-04-09 12:39:57 -07:00
parent 60fcec2a61
commit 75ecfdfa57

22
aqi.ino
View File

@@ -6,6 +6,7 @@
SensirionI2CSen44 sen44; SensirionI2CSen44 sen44;
// initialize the library with the numbers of the interface pins // initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buttonPin = 6;
float heatIndex(float t, float rh) { float heatIndex(float t, float rh) {
float hi = 0.0; float hi = 0.0;
@@ -44,6 +45,9 @@ void setup() {
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 2);
// set up the button pin
pinMode(buttonPin, INPUT_PULLUP);
Wire.begin(); Wire.begin();
uint16_t error; uint16_t error;
@@ -104,6 +108,23 @@ void loop() {
lcd.clear(); lcd.clear();
if (digitalRead(buttonPin) == LOW) {
lcd.setCursor(0, 0);
lcd.print("1:");
lcd.print(massConcentrationPm1p0);
lcd.setCursor(8, 0);
lcd.print("2:");
lcd.print(massConcentrationPm2p5);
lcd.setCursor(0, 1);
lcd.print("4:");
lcd.print(massConcentrationPm4p0);
lcd.setCursor(8, 1);
lcd.print("10:");
lcd.print(massConcentrationPm10p0);
} else {
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print("t:"); lcd.print("t:");
lcd.print(round(ambientTemperature)); lcd.print(round(ambientTemperature));
@@ -119,6 +140,7 @@ void loop() {
lcd.setCursor(8, 1); lcd.setCursor(8, 1);
lcd.print("v:"); lcd.print("v:");
lcd.print(vocIndex, 0); lcd.print(vocIndex, 0);
}
//Serial.println("------------"); //Serial.println("------------");
//Serial.print("Voc:"); //Serial.print("Voc:");