1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| int relais = 2;
int relais_Ballon = 3;
const int Led_ON = 4;
const int Led_OFF = 6;
const int Led_Ballon_ON = 5;
const int Led_Balon_OFF = 7;
bool etat;
char donnee;
void setup()
{
Serial.begin(9600);
pinMode(relais, OUTPUT);
pinMode(Led_ON, INPUT);
pinMode(Led_OFF, INPUT);
digitalWrite(relais, HIGH);
digitalWrite(Led_ON, LOW);
digitalWrite(Led_OFF, LOW);
etat = false;
}
void loop()
{
if (Serial.available() > 0)
{
donnee=Serial.read();
if (donnee == '1')
{
etat?digitalWrite(relais, HIGH):digitalWrite(relais, LOW);
etat = !etat;
delay(1000);
LireON_OFF();
}
}
}
void LireON_OFF()
{
if (relais = HIGH)
{
Serial.println("-----ON----");
digitalWrite(Led_ON, HIGH);
digitalWrite(Led_OFF,LOW);
delay(200);
}
if (relais = LOW)
{
Serial.println("----OFF----");
digitalWrite(Led_OFF, HIGH);
digitalWrite(Led_ON, LOW);
delay(200);
}
} |
Partager