{"id":1476,"date":"2021-10-26T14:56:12","date_gmt":"2021-10-26T19:56:12","guid":{"rendered":"http:\/\/ve2cuy.com\/420-1c4\/?page_id=1476"},"modified":"2024-03-18T09:38:48","modified_gmt":"2024-03-18T14:38:48","slug":"detecteur-de-mouvements","status":"publish","type":"page","link":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/detecteur-de-mouvements\/","title":{"rendered":"D\u00e9tecteur de mouvements"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Grove Adjustable <a href=\"https:\/\/wiki.seeedstudio.com\/Grove-Adjustable_PIR_Motion_Sensor\/\">PIR Motion Sensor<\/a><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/detecteur-mouvements.jpg\" alt=\"\" class=\"wp-image-1477\" srcset=\"https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/detecteur-mouvements.jpg 1024w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/detecteur-mouvements-300x225.jpg 300w, https:\/\/ve2cuy.com\/420-1c4\/wp-content\/uploads\/2021\/10\/detecteur-mouvements-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Type de connexion: <span class=\"has-inline-color has-vivid-green-cyan-color\">digitale<\/span><\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Exemple d&rsquo;utilisation<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/*\n    Auteur:       Alain Boudreault\n    Date:         2021.10.26\n    Client\u00e8le:    \u00c9tudiant(e)s du cours 420-1C4: Objets connect\u00e9s de CSTJ.\n    Description:  Allumer une DEL si une personne est d\u00e9tect\u00e9e dans la zone\n                  de captation du module Grove 'Adjustable PIR Motion Sensor'.\n\n    R\u00e9f\u00e9rence:    https:\/\/wiki.seeedstudio.com\/Grove-Adjustable_PIR_Motion_Sensor\/              \n*\/\n\n#define PIR_MOTION_SENSOR 6 \n#define LED 3. \n \nvoid setup()\n{\n    \/\/ Initialiser les broches pour la DEL et le d\u00e9tecteur de mouvements\n    initialiserLesBrochesDuArduino();\n} \/\/ setup\n \nvoid loop() \n{\n    iYatiKekun() ? allumerLaDEL() : eteindreLaDEL();\n} \/\/ loop\n\n\/* ---------------------------------------------------------\n   Fonction: Initialiser les broches du Arduino   \n   Retour:   void   \n   ------------------------------------------------------ *\/\nvoid initialiserLesBrochesDuArduino()\n{\n    pinMode(PIR_MOTION_SENSOR, INPUT);\n    pinMode(LED,OUTPUT);\n} \/\/ initialiserLesBrochesDuArduino\n\n\/* ---------------------------------------------------------\n   Fonction: Allumer la DEL connect\u00e9e \u00e0 la broche DEL   \n   Retour:   void   \n   ------------------------------------------------------ *\/\nvoid allumerLaDEL()\n{\n    digitalWrite(LED,HIGH);\n} \/\/ allumerLaDEL\n\n\/* ---------------------------------------------------------\n   Fonction: \u00c9teindre la DEL connect\u00e9e \u00e0 la broche DEL   \n   Retour:   void   \n   ------------------------------------------------------ *\/\nvoid eteindreLaDEL()\n{\n    digitalWrite(LED,LOW);\n} \/\/ eteindreLaDEL\n\n\/* ---------------------------------------------------------\n   Fonction: D\u00e9tecter une personne dans la zone du capteur.   \n   Retour:   boolean, retourne 'vrai' s'il y a d\u00e9tection.   \n   ---------------------------------------------------------        \n*\/\nboolean iYatiKekun()\n{\n    int sensorValue = digitalRead(PIR_MOTION_SENSOR);\n    if(sensorValue == HIGH) \/\/ si valeur du capteur PIR est HIGH (1) alors\n    {\n        return true;   \/\/ Oh, il y a un coquin qui est pass\u00e9 devant le capteur!\n    }\n    else\n    {\n        return false;  \/\/ Et ben non :-(, pas de visite ...\n    }\n}\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"has-vivid-red-color has-text-color wp-block-heading\">D\u00e9fi informatique <\/h2>\n\n\n\n<p>Optimiser la fonction <em><strong>iYaTiKekun<\/strong><\/em>() pour utiliser le moins de code possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grove Adjustable PIR Motion Sensor Type de connexion: digitale Exemple d&rsquo;utilisation D\u00e9fi informatique Optimiser la fonction iYaTiKekun() pour utiliser le moins de code possible.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ub_ctt_via":"","footnotes":""},"class_list":["post-1476","page","type-page","status-publish","hentry"],"featured_image_src":null,"_links":{"self":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages\/1476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/comments?post=1476"}],"version-history":[{"count":5,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages\/1476\/revisions"}],"predecessor-version":[{"id":1537,"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/pages\/1476\/revisions\/1537"}],"wp:attachment":[{"href":"https:\/\/ve2cuy.com\/420-1c4\/index.php\/wp-json\/wp\/v2\/media?parent=1476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}