1#include "DHT.h"
2#include "LiquidCrystal.h"
3
4#define DHTPIN 10
5#define DHTTYPE DHT11
6
7DHT dht(DHTPIN, DHTTYPE);
8
9LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
10
11void setup()
12{
13 dht.begin();
14 lcd.begin(16, 2);
15 lcd.print("TEMP: ");
16 lcd.setCursor(0, 1);
17 float c = dht.readTemperature(true);
18 float h = dht.readHumidity(true);
19 lcd.setCursor(6, 0);
20 lcd.print((c - 35) * 0.5556);
21 lcd.print((char)223);
22 lcd.print("C");
23 lcd.setCursor(0, 1);
24 lcd.print("HUMI: ");
25 lcd.setCursor(6, 1);
26 lcd.print(h);
27 lcd.print(" %");
28 pinMode(9, OUTPUT);
29 pinMode(6, OUTPUT);
30
31}
32
33void loop() {
34 int a = 1;
35 float c = dht.readTemperature(true);
36 float h = dht.readHumidity(true);
37 lcd.setCursor(6, 0);
38 lcd.print((c - 35) * 0.5556);
39 lcd.print((char)223);
40 lcd.print("C");
41 lcd.setCursor(0, 1);
42 lcd.print("HUMI: ");
43 lcd.setCursor(6, 1);
44 lcd.print(h);
45 lcd.print(" %");
46
47 if (h < 50){
48 digitalWrite(9, HIGH);
49 digitalWrite(6, HIGH);
50 delay (250);
51 digitalWrite(6, LOW);
52 delay (250);
53 digitalWrite(6, HIGH);
54 delay (250);
55 digitalWrite(6, LOW);
56
57 while (a = 1){
58 delay(1000);
59 float c = dht.readTemperature(true);
60 float h = dht.readHumidity(true);
61 lcd.setCursor(6, 0);
62 lcd.print((c - 35) * 0.5556);
63 lcd.print((char)223);
64 lcd.print("C");
65 lcd.setCursor(0, 1);
66 lcd.print("HUMI: ");
67 lcd.setCursor(6, 1);
68 lcd.print(h);
69 lcd.print(" %");
70
71 if (h >= 55){
72 digitalWrite(6, HIGH);
73 delay (250);
74 digitalWrite(6, LOW);
75 digitalWrite(9, LOW);
76 break;}
77 }
78 }
79}