|
(Balise : Nouvelle redirection) |
Ligne 1 : |
Ligne 1 : |
− | {{Item
| + | #REDIRECTION [[Item:Détecteur de Mouvement HC-SR501]] |
− | |Main_Picture=Item-Motion_Sensor_HC-SR501_motion_sensor_hc_sr-501.jpg
| |
− | |Description=Détecteur de mouvement PIR (Passive Infra Red)
| |
− | |Categories=Matériel, Parts
| |
− | |Cost=0.72
| |
− | |Currency=EUR (€)
| |
− | |ItemLongDescription={{Info|Il doit être alimenté en 5V}}
| |
− | | |
− | plus d'infos : https://pdf1.alldatasheet.fr/datasheet-pdf/view/1131987/ETC2/HC-SR501.html
| |
− | | |
− | <br />
| |
− | | |
− | =Caractéristiques=
| |
− | <br />
| |
− | | |
− | *alimentation maxi : 5V
| |
− | | |
− | =Bibliothèque : =
| |
− | Pour utiliser le détecteur de mouvement il n'y a besoin d'aucunes bibliothèques
| |
− | | |
− | =Câblage : =
| |
− | {{#annotatedImageLight:Fichier:Item Motion Sensor HC-SR501.png|0=509px|hash=|jsondata=|mediaClass=Image|type=frameless|alt=Item Motion Sensor HC-SR501|align=center|src=https://www.wikidebrouillard.org/images/9/91/Item_Motion_Sensor_HC-SR501.png|href=./Fichier:Item Motion Sensor HC-SR501.png|resource=./Fichier:Item Motion Sensor HC-SR501.png|caption=|size=509px}}
| |
− | =Le code minimal : =
| |
− | {| class="wikitable" cellspacing="0" border="0"
| |
− | | height="17" bgcolor="#999999" align="left" |
| |
− | | valign="middle" bgcolor="#999999" align="center" |
| |
− | | bgcolor="#999999" align="center" |Motion Sensor HC SR-501
| |
− | |-
| |
− | | rowspan="2" valign="middle" height="49" bgcolor="#999999" align="center" |Avant le Setup
| |
− | | valign="middle" bgcolor="#999999" align="center" |Importation de la bibliothèque
| |
− | | valign="middle" align="left" |Aucunes bibliothèques
| |
− | |-
| |
− | | valign="middle" bgcolor="#999999" align="center" |Création de l’objet
| |
− | | valign="middle" align="left" |#define pirPin <numéro de broche>; // je défini la broche
| |
− | int val = LOW;
| |
− | | |
− | bool motionState = false;
| |
− | |-
| |
− | | valign="middle" height="17" bgcolor="#999999" align="center" |Dans le Setup
| |
− | | valign="middle" bgcolor="#999999" align="center" |Démarrage de l’objet
| |
− | | valign="middle" align="left" |pinMode(pirPin, INPUT);
| |
− | |-
| |
− | | valign="middle" height="41" bgcolor="#999999" align="center" |Dans le Loop
| |
− | | valign="middle" bgcolor="#999999" align="center" |Utilisation
| |
− | | valign="middle" align="left" |val = digitalRead(pirPin);
| |
− | if (motionState == false)
| |
− | |}
| |
− | =Autres fonctionnalités=
| |
− | Aucune autres fonctionnalités
| |
− | =Exemple : =
| |
− | <syntaxhighlight lang="arduino" line="1" start="1">
| |
− | #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;
| |
− | }
| |
− | }
| |
− | }
| |
− | | |
− | </syntaxhighlight><br />
| |
− | }}
| |
− | {{Tuto Status
| |
− | |Complete=Published
| |
− | }}
| |