//Librairies
#include <LiquidCrystal.h>
#include <DHT.h>
#define dhtType DHT11
int dhtPin = 0;//D3
int rs = 15 ;//D8
int en = 16;//D0
int db4 = 2;//D4
int db5 = 14;//D5
int db6 = 12;//D6
int db7 = 13;//D7
int ledRedPin = 5;//D1
int ledBleuPin=4;//D2
float temperature;
float humidity;
LiquidCrystal lcd(rs, en, db4, db5, db6, db7);
DHT dht(dhtPin, dhtType);
void setup()
{ pinMode(ledRedPin, OUTPUT);
pinMode(ledBleuPin, OUTPUT);
lcd.begin(16, 2);
Serial.begin(9600);
dht.begin();
}
void loop()
{
temperature = dht.readTemperature();
humidity = dht.readHumidity();
lcd.setCursor(0,0);
Serial.println( temperature);
lcd.print( » T= »);
lcd.print(temperature);
lcd.print(« C « );
int k=round(humidity);
lcd.print(« H= »);
lcd.print(k);
lcd.print(« % »);
delay(500);
if (temperature > 26.00)
{
digitalWrite(ledRedPin, HIGH);
digitalWrite(ledBleuPin, LOW);
lcd.setCursor(0,1);
lcd.print( » Danger « );
delay(500);
lcd.clear();
}
if (temperature < 26.00)
{
digitalWrite(ledBleuPin, HIGH);
digitalWrite(ledRedPin, LOW);
lcd.setCursor(0,1);
lcd.print( » Safe »);
delay(500);
}
lcd.clear();
}