#include <TSServo.h>
#include <DHT.h>
#include <rgb_lcd.h>
TSServo servo_pin_4;
int _ABVAR_1_compt = 0 ;
int _ABVAR_2_affich = 0 ;
int _ABVAR_3_Lum = 0 ;
void __ardublockDigitalWrite(int pinNumber, boolean status)
{
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, status);
}
int _ABVAR_4_TempInt = 0 ;
DHT dht22_pin_3(3, 22);
int _ABVAR_5_HumidInt = 0 ;
int _ABVAR_6_HumidTerre = 0 ;
rgb_lcd rgbLcd;
void Affichage();
void Ouverture_serre();
void setup()
{
servo_pin_4.attach(4);
dht22_pin_3.begin();
rgbLcd.begin(16,2);
rgbLcd.setRGB(constrain(0,0,255),constrain(255,0,255),constrain(0,0,255));
servo_pin_4.write( 600, 20, 0, 180 );
_ABVAR_1_compt = 0 ;
_ABVAR_2_affich = 0 ;
}
void loop()
{
_ABVAR_3_Lum = analogRead(1) ;
if (( ( _ABVAR_3_Lum ) < ( 500 ) ))
{
__ardublockDigitalWrite(6, HIGH);
while ( ( ( _ABVAR_1_compt ) < ( 150 ) ) )
{
_ABVAR_4_TempInt = dht22_pin_3.readTemperature() ;
_ABVAR_5_HumidInt = dht22_pin_3.readHumidity() ;
_ABVAR_6_HumidTerre = analogRead(0) ;
Affichage();
Ouverture_serre();
_ABVAR_1_compt = ( _ABVAR_1_compt + 1 );
}
__ardublockDigitalWrite(6, LOW);
delay( 1000 );
_ABVAR_1_compt = 0;
}
else
{
if (( ( _ABVAR_3_Lum ) > ( 500 ) ))
{
__ardublockDigitalWrite(6, LOW);
while ( ( ( _ABVAR_1_compt ) < ( 150 ) ) )
{
_ABVAR_4_TempInt = dht22_pin_3.readTemperature() ;
_ABVAR_5_HumidInt = dht22_pin_3.readHumidity() ;
_ABVAR_6_HumidTerre = analogRead(0) ;
Affichage();
Ouverture_serre();
_ABVAR_1_compt = ( _ABVAR_1_compt + 1 );
}
}
_ABVAR_1_compt = 0;
}
}
void Ouverture_serre()
{
if (( ( _ABVAR_4_TempInt ) > ( 25 ) ))
{
servo_pin_4.write( 230, 20, 0, 180 );
}
if (( ( _ABVAR_4_TempInt ) <= ( 23 ) ))
{
servo_pin_4.write( 610, 20, 0, 180 );
}
}
void Affichage()
{
if (( ( _ABVAR_2_affich ) == ( 0 ) ))
{
rgbLcd.setCursor(0, 0);
rgbLcd.print("Temp Int:" );
rgbLcd.print(_ABVAR_4_TempInt );
rgbLcd.print(" ");
rgbLcd.setCursor(0, 1);
rgbLcd.print("Humid Int:" );
rgbLcd.print(_ABVAR_5_HumidInt );
rgbLcd.print(" ");
_ABVAR_2_affich = ( _ABVAR_2_affich + 1 );
delay( 1 * 1000);
}
if (( ( _ABVAR_2_affich ) == ( 1 ) ))
{
if (( ( _ABVAR_6_HumidTerre ) < ( 300 ) ))
{
rgbLcd.setCursor(0, 1);
rgbLcd.print("Sol sec :o" );
rgbLcd.print(" ");
}
if (( ( ( _ABVAR_6_HumidTerre ) > ( 300 ) ) && ( ( _ABVAR_6_HumidTerre ) < ( 700 ) ) ))
{
rgbLcd.setCursor(0, 1);
rgbLcd.print("Sol mouille ^-^" );
rgbLcd.print(" ");
}
if (( ( _ABVAR_6_HumidTerre ) > ( 700 ) ))
{
rgbLcd.setCursor(0, 1);
rgbLcd.print("J'ai plus soif" );
rgbLcd.print(" ");
}
delay( 1 * 1000);
_ABVAR_2_affich = 0;
}
}
Comments