m (Djbrown a déplacé la page Item:Motion Sensor HC-SR501 vers Item:Détecteur de Mouvement HC-SR501) |
|
(Aucune différence)
| |
plus d'infos : https://pdf1.alldatasheet.fr/datasheet-pdf/view/1131987/ETC2/HC-SR501.html
Pour utiliser le détecteur de mouvement il n'y a besoin d'aucunes bibliothèques
| Motion Sensor HC SR-501 | ||
| Avant le Setup | Importation de la bibliothèque | Aucunes bibliothèques |
| Création de l’objet | #define pirPin <numéro de broche>; // je défini la broche
int val = LOW; bool motionState = false; | |
| Dans le Setup | Démarrage de l’objet | pinMode(pirPin, INPUT); |
| Dans le Loop | Utilisation | val = digitalRead(pirPin);
if (motionState == false) |
Aucune autres fonctionnalités
#define pirPin 2
int val = LOW;
bool motionState = false;
void setup() {
Serial.begin(9600);
pinMode(pirPin, INPUT);
}
void loop() {
val = digitalRead(pirPin);
if (val == HIGH) {
if (motionState == false) {
Serial.println("Mouvement détecté !");
motionState = true;
}
} else if (val == LOW) {
if (motionState == true) {
Serial.println("Mouvement non détecté !");
motionState = false;
}
}
}Item-Motion_Sensor_HC-SR501_motion_sensor_hc_sr-501.jpg Published
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #