my project is to have 4 DHT11 running, connected to an lcd screen. there is a push button that will change between the sensors. The program was working before I added the two extra sensors. Now the program will keep running the cases without clearing the screen.???
#include "DHT.h"
#define DHTPIN 2
#define DHTPIN 3
#define DHTPIN 12;
#define DHTPIN 9;
#define DHTTYPE DHT11
DHT dht1(2, DHT11);
DHT dht2(3, DHT11);
DHT dht3(12, DHT11);
DHT dht4(9, DHT11);
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 7, d5 = 6, d6 = 5, d7 = 4;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int button = 8;
int buttonState = 0;
int count = 0;
void setup() {
pinMode(button, INPUT);
dht1.begin();
dht2.begin();
dht3.begin();
dht4.begin();
lcd.begin(16, 2);
}
void loop() {
buttonState = digitalRead(button);
float h1 = dht1.readHumidity();
float f1 = dht1.readTemperature(true);
float h2 = dht2.readHumidity();
float f2 = dht2.readTemperature(true);
float h3 = dht3.readHumidity();
float f3 = dht3.readTemperature(true);
float h4 = dht4.readHumidity();
float f4 = dht4.readTemperature(true);
if (buttonState == HIGH) {
delay(100);
count++;
}
if (count > 4) {
count = 0;
}
switch (count) {
case 0:
lcd.clear();
lcd.print("marks cloaca");
lcd.setCursor(0, 0);
delay(100);
break;
case 1:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("T ");
lcd.print(f1);
lcd.setCursor(0, 1);
lcd.print("H ");
lcd.print(h1);
delay(100);
break;
case 2:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("T ");
lcd.print(f2);
lcd.setCursor(0, 1);
lcd.print("H ");
lcd.print(h2);
delay(100);
break;
case 3:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("T ");
lcd.print(f3);
lcd.setCursor(0, 1);
lcd.print("H ");
lcd.print(h3);
delay(100);
break;
case 4:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("T ");
lcd.print(f4);
lcd.setCursor(0, 1);
lcd.print("H ");
lcd.print(h4);
delay(100);
break;
}
}