#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 6
LiquidCrystal lcd(7,8,9,10,11,12);
#define DHTTYPE DHT22
DHT dht (DHTPIN,DHTTYPE);
void setup() {
dht.begin();
lcd.begin(16,2);
// put your setup code here, to run once:
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(t) || isnan(h)) {
lcd.setCursor(0,0);
lcd.print("Failed to read from DHT");
} else {
lcd.clear();
lcd.setCursor(1,0);
lcd.print("Humidity: ");
lcd.print(h);
lcd.print("%");
lcd.setCursor(1,1);
lcd.print("Temp: ");
lcd.print(t);
lcd.print("c");
for(int positionCounter = 0; positionCounter < 16;
positionCounter++){
lcd.scrollDisplayLeft();
delay(1000);
}
lcd.clear();
lcd.setCursor(16,0);
lcd.print("Humidity: ");
lcd.print(h);
lcd.print("%");
lcd.setCursor(16,1);
lcd.print("Temp: ");
lcd.print(t);
lcd.print("c");
for(int positionCounter = 0; positionCounter < 16;
positionCounter++){
lcd.scrollDisplayLeft();
delay(1000);
}
}
}
// put your main code here, to run repeatedly: