Étape 2: Arduino
si (Serial.available() < = 0) Serial.println ("porte fermée");
// **************************************************************************************************
pour une utilisation avec simpleTweet_01_python.py
const int magReed_pin = 10 ; Numéro d’identification
int magReed_val = 0 ;
int currentDoorState = 1 ; commencer w / circuit ouvert
int previousDoorState = 1 ;
void setup() {}
Serial.Begin(9600) ;
pinMode (magReed_pin, entrée) ;
}
void loop() {}
watchTheDoor() ;
}
void watchTheDoor() {}
magReed_val = digitalRead(magReed_pin) ;
Si (magReed_val == faible) {/ / open
currentDoorState = 1 ;
Si (previousDoorState! = currentDoorState) {}
Si (Serial.available() < = 0) Serial.println ("porte ouverte") ;
}
}
Si (magReed_val == HIGH) {/ / fermé
currentDoorState = 2 ;
Si (previousDoorState! = currentDoorState) {}
Si (Serial.available() < = 0) Serial.println ("porte fermée") ;
}
}
previousDoorState = currentDoorState ;
Delay(300) ;
}
// **************************************************************************************************