add more parameters on button press
This commit is contained in:
46
aqi.ino
46
aqi.ino
@@ -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,21 +108,39 @@ void loop() {
|
|||||||
|
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
|
|
||||||
lcd.setCursor(0, 0);
|
if (digitalRead(buttonPin) == LOW) {
|
||||||
lcd.print("t:");
|
lcd.setCursor(0, 0);
|
||||||
lcd.print(round(ambientTemperature));
|
lcd.print("1:");
|
||||||
|
lcd.print(massConcentrationPm1p0);
|
||||||
|
|
||||||
lcd.setCursor(8, 0);
|
lcd.setCursor(8, 0);
|
||||||
lcd.print("h:");
|
lcd.print("2:");
|
||||||
lcd.print(round(ambientHumidity));
|
lcd.print(massConcentrationPm2p5);
|
||||||
|
|
||||||
lcd.setCursor(0, 1);
|
lcd.setCursor(0, 1);
|
||||||
lcd.print("f:");
|
lcd.print("4:");
|
||||||
lcd.print(round(feelsLikeTemperature));
|
lcd.print(massConcentrationPm4p0);
|
||||||
|
|
||||||
lcd.setCursor(8, 1);
|
lcd.setCursor(8, 1);
|
||||||
lcd.print("v:");
|
lcd.print("10:");
|
||||||
lcd.print(vocIndex, 0);
|
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.println("------------");
|
||||||
//Serial.print("Voc:");
|
//Serial.print("Voc:");
|
||||||
|
|||||||
Reference in New Issue
Block a user