#include "DHT.h"
#include "LiquidCrystal.h"
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#define DHTPIN 2
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
#define Andrew 4
#define Andrew2 13
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
Serial.println(F("Meteostanice"));
lcd.begin(16, 2);
dht.begin();
lcd.print("Vitejte");
delay(2000);
lcd.clear();
}
void loop() {
float teplota = dht.readTemperature();
float vlhkost = dht.readHumidity();
// Check if any reads failed and exit early (to try again).
if (isnan(teplota) || isnan(vlhkost)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
if (teplota > 21) {
lcd.print("je tu horko");
digitalWrite(Andrew, HIGH);
digitalWrite(Andrew2, LOW);
}
if (teplota < 18) {
lcd.print("je tu zima");
digitalWrite (Andrew2, HIGH);
digitalWrite(Andrew, LOW);
}
delay(3000);
lcd.clear();
lcd.print(F("Teplota: "));
lcd.print(teplota);
delay(3000);
lcd.clear();
Serial.print(F("Vlhkost: "));
Serial.print(vlhkost);
Serial.print(F("% Teplota: "));
Serial.print(teplota);
Serial.println(F("°C "));
// Wait a few seconds between measurements.
delay(100);
}