#include <DHT.h>
#include <Servo.h>
#define tempInterPin 8
#define tempExtPin 9
int temperatureInter=0;
int temperatureExter=0;
int t1=0;
int t2=0;
int chauffOn=1;
int froidOn=1;
Servo fenetre;
DHT tempInter=DHT(8,DHT22);
DHT tempExt=DHT(9,DHT22);
void setup() {
tempInter.begin();
tempExt.begin();
Serial.begin(9600);
fenetre.attach(10);
fenetre.write(0);
}
void loop() {
delay(1000);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
temperatureInter=tempInter.readTemperature();
temperatureExter=tempExt.readTemperature();
Serial.print("temperature interieur ");
Serial.println(temperatureInter);
Serial.print("temperature exterieur ");
Serial.println(temperatureExter);
/*delay(1000);
fenetre.write(0);
delay(1000);
fenetre.write(90);
delay(1000);*/
if( temperatureInter>39 && temperatureExter>39){
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
fenetre.write(90);
if(chauffOn==1){
t1=millis();
chauffOn=0;
}
}else if(temperatureInter<20 && temperatureExter<20){
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
fenetre.write(90);
if(froidOn==1){
t1=millis();
froidOn=0;
}
}else{
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
digitalWrite(11, LOW);
if(temperatureInter>25 && temperatureInter<38 ){
t2=millis();
if(t2-t1>7200){
}
chauffOn=1;
froidOn=1;
t1=0;
}
}
}