#include<LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 13
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
int lRed = 2;
int lBlu = 4;
int lGrn = 3;
int temp = A4;
LiquidCrystal lcd(12, 11, 9, 10, 6, 5);
void setup() {
Serial.begin(9600);
Serial.println(F("DHT22 teste!"));
lcd.begin(16, 2);
dht.begin();
pinMode(lRed, OUTPUT);
pinMode(lBlu, OUTPUT);
pinMode(lGrn, OUTPUT);
}
void off() {
digitalWrite(lRed, LOW);
digitalWrite(lBlu, LOW);
digitalWrite(lGrn, LOW);
lcd.clear();
}
void loop() {;
float u = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
lcd.print(F("Umi: "));
lcd.print(u);
lcd.setCursor(0,1);
lcd.print(F("Temp: "));
lcd.print(t);
lcd.print(F("C"));
if(t < 20) {
/*=================================================
Se a temperatura estiver abaixo do ideal,aparece no
LCD a palavra Frio e uma luz azul é acendida.
===================================================*/
digitalWrite(lBlu, HIGH);
delay (2000);
off();
} else if (t > 25){
/*================================================
Se a temperatura estiver acima do ideal,aparece no
LCD a palavra Quente, o motor ativa (simulando um
ventilador)e uma luz vermelha é acendida.
==================================================*/
digitalWrite(lRed, HIGH);
delay (2000);
off();
} else{
/*=================================================
Se a temperatura estiver no ideal, aparece no LCD
a sentença TEMP Ideal e uma luz verde é acendida.
=================================================*/
digitalWrite(lGrn, HIGH);
delay (2000);
off();
}
if(u < 40) {
/*=================================================
Se a temperatura estiver abaixo do ideal,aparece no
LCD a palavra Frio e uma luz azul é acendida.
===================================================*/
digitalWrite(lBlu, HIGH);
delay (2000);
off();
} else if (u > 65){
/*================================================
Se a temperatura estiver acima do ideal,aparece no
LCD a palavra Quente, o motor ativa (simulando um
ventilador)e uma luz vermelha é acendida.
==================================================*/
digitalWrite(lRed, HIGH);
delay (2000);
off();
} else{
/*=================================================
Se a temperatura estiver no ideal, aparece no LCD
a sentença TEMP Ideal e uma luz verde é acendida.
=================================================*/
digitalWrite(lGrn, HIGH);
delay (2000);
off();
}
/* */
}