#include <LiquidCrystal.h>
#include <DHT.h>
#define DHTPIN 6
#define DHTTYPE DHT22
#define TUP 4
#define TDN 3
#define OUT 5
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void setup() {
lcd.begin(16, 2);
dht.begin();
pinMode(TUP,INPUT_PULLUP);
pinMode(TDN,INPUT_PULLUP);
pinMode(OUT, OUTPUT);
}
float tempLast = 0, humLast = 0;
float tempSet = 38;
void loop() {
float temperature;
float humidity;
temperature = dht.readTemperature();
humidity = dht.readHumidity();
if ((tempLast != temperature) || (humLast != humidity)) {
tempLast = temperature;
humLast = humidity;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" \xDF");
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Hum: ");
lcd.print(humidity);
lcd.print(" %");
}
if (digitalRead(TUP) == LOW) {
tempSet += .1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("T. Set: ");
lcd.print(tempSet);
lcd.print(" \xDF");
lcd.print("C");
delay(100);
}
if (digitalRead(TDN) == LOW) {
tempSet -= .1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("T. Set: ");
lcd.print(tempSet);
lcd.print(" \xDF");
lcd.print("C");
delay(100);
}
if (tempSet > temperature) digitalWrite(OUT, HIGH);
else digitalWrite(OUT, LOW);
}