#include "DHT.h"
#include "LiquidCrystal.h"
#define DHTPIN 10
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
dht.begin();
lcd.begin(16, 2);
lcd.print("TEMP: ");
lcd.setCursor(0, 1);
float c = dht.readTemperature(true);
float h = dht.readHumidity(true);
lcd.setCursor(6, 0);
lcd.print((c - 35) * 0.5556);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("HUMI: ");
lcd.setCursor(6, 1);
lcd.print(h);
lcd.print(" %");
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
// init------------------------------------
}
void loop() {
int a = 1;
float c = dht.readTemperature(true);
float h = dht.readHumidity(true);
lcd.setCursor(6, 0);
lcd.print((c - 35) * 0.5556);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("HUMI: ");
lcd.setCursor(6, 1);
lcd.print(h);
lcd.print(" %");
//--------------------------------------------
if (h < 50){
digitalWrite(9, HIGH);
digitalWrite(6, HIGH);
delay (250);
digitalWrite(6, LOW);
delay (250);
digitalWrite(6, HIGH);
delay (250);
digitalWrite(6, LOW);
// send pulse 2X-----------------------------
while (a = 1){
delay(1000);
float c = dht.readTemperature(true);
float h = dht.readHumidity(true);
lcd.setCursor(6, 0);
lcd.print((c - 35) * 0.5556);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("HUMI: ");
lcd.setCursor(6, 1);
lcd.print(h);
lcd.print(" %");
// LCD--------------------------------------
if (h >= 55){
digitalWrite(6, HIGH);
delay (250);
digitalWrite(6, LOW);
digitalWrite(9, LOW);
break;}
}
}
}
Comments
Please log in or sign up to comment.