#include #include #include "DHT.h" #define DHTPIN 2 // what digital pin we're connected to #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 LiquidCrystal_I2C lcd(0x20,16,2); DHT dht(DHTPIN, DHTTYPE); int limiet1 = 80; boolean schakelaar = false; int teller = 0; int loper = 0; int gevoeligheid = 4; void setup() { Serial.begin(9600); lcd.init(); lcd.backlight(); delay(2000); lcd.setCursor(0,0); lcd.print("klimaat control"); delay(3000); lcd.clear(); delay(2000); lcd.setBacklight(LOW); delay(2000); lcd.setBacklight(HIGH); dht.begin(); } void loop() { delay(2000); float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } lcd.setCursor(0,1); lcd.print("RV:"); lcd.setCursor(0,0); lcd.print("T :"); lcd.setCursor(7,1); lcd.print("LIM:"); lcd.setCursor(11,1); lcd.print(limiet1); lcd.setCursor(3,1); lcd.print(int(h)); lcd.setCursor(3,0); lcd.print(int(t)); // delay(2000); if (h > limiet1) { loper = 0; teller = teller + 1; lcd.setCursor(15,0); lcd.print(teller); lcd.setCursor(15,1); lcd.print(loper); if (teller == gevoeligheid) { schakelaar = true; teller = 0; } } if (schakelaar == true) { lcd.setCursor(7,0); lcd.print("FAN AAN"); } if (h <= limiet1) { teller = 0; loper = loper + 1; lcd.setCursor(15,1); //controle lcd.print(loper); //controle lcd.setCursor(15,0); //controle lcd.print(teller); //controle if (loper == gevoeligheid) { schakelaar = false; loper = 0; } } if (schakelaar == false) { lcd.setCursor(7,0); lcd.print("FAN UIT"); } }