#include <DHT.h>
#include <Servo.h>
#define DHT_PIN1 2
#define DHT_PIN2 6
#define DHT_TYPE DHT22
#define SERVO_PIN 11
#define LED_Rouge 9
#define LED_vert 13
#define LED_Jaune 4
#define LED_Orange 5
int position =0;
DHT dht(DHT_PIN1,DHT_PIN2,DHT_TYPE);
Servo window;
void setup() {
pinMode(LED_Rouge,OUTPUT);
pinMode(LED_vert,OUTPUT);
pinMode(LED_Jaune,OUTPUT);
pinMode(LED_Orange,OUTPUT);
pinMode(DHT_PIN1,INPUT);
pinMode(DHT_PIN2,INPUT);
Serial.begin(9600);
dht.begin();
window.attach(SERVO_PIN);
}
void loop() {
float tempext = dht.readTemperature();
float tempint = dht.readTemperature();
if(tempint>26 && tempext>26){
Serial.println("Froidissement CONDITION ACTIVER");
digitalWrite(LED_vert, HIGH);
} else{
if(tempint<20 && tempext>20){
Serial.println("CHAUD CONDITION ACTIVER");
digitalWrite(LED_Orange, HIGH);
}
}
if(tempint>20 && tempint<26){
Serial.println("VEILLe CONDITION ACTIVER");
digitalWrite(LED_Jaune, HIGH);
}
if(position!=0){
Serial.println("VEILLe CONDITION ACTIVER (MODE EN PAUSE)");
digitalWrite(LED_Jaune, HIGH);
}
if(tempint>27){
Serial.println("ALARME CONDITION ");
digitalWrite(LED_Rouge, HIGH);
}
}