#include <Servo.h>
#include <DHT.h>
#define DHTPIN 2
#define DHTPIN 7
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
Servo servo;
const int greenLedPin = 5;
const int orangeLedPin = 3;
const int yellowLedPin = 4;
const int redLedPin = 13;
Servo port;
void setup() {
dht.begin();
port.attach(6);
pinMode(greenLedPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
pinMode(orangeLedPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
float tempext = dht.readTemperature();
float tempint = dht.readTemperature();
port.write(180);// le port est ferme
// myservo1.write(0); //le port est ouvert
if (port.read()==0) {
digitalWrite(yellowLedPin, HIGH);
digitalWrite(greenLedPin, LOW);
digitalWrite(redLedPin, LOW);
digitalWrite(orangeLedPin, LOW);
}else{
if ((tempext > 26) || (tempint > 26)) {
digitalWrite(greenLedPin, HIGH);
digitalWrite(redLedPin, LOW);
digitalWrite(orangeLedPin, LOW);
digitalWrite(yellowLedPin, LOW);
if (tempint >= 27){
digitalWrite(redLedPin, HIGH);
delay(3000);
}
Serial.println("refroidissement");
} else if ((tempext<20) || (tempint<20) ){
digitalWrite(greenLedPin,LOW );
digitalWrite(redLedPin, LOW);
digitalWrite(orangeLedPin, HIGH);
digitalWrite(yellowLedPin, LOW);
Serial.println(" chauffage");
} else {
digitalWrite(yellowLedPin, HIGH);
digitalWrite(greenLedPin, LOW);
digitalWrite(redLedPin, LOW);
digitalWrite(orangeLedPin, LOW);
Serial.println(" en veille");
delay(3000);
}
}
delay(3000);
}