{"id":6399,"date":"2023-09-12T17:25:08","date_gmt":"2023-09-12T15:25:08","guid":{"rendered":"https:\/\/www.ardpylab.fr\/?page_id=6399"},"modified":"2023-09-13T17:45:02","modified_gmt":"2023-09-13T15:45:02","slug":"des-sketchs-a-ajouter-a-ardpylog-suite-2","status":"publish","type":"page","link":"https:\/\/www.ardpylab.fr\/?page_id=6399","title":{"rendered":"Des sketchs \u00e0 ajouter \u00e0 ArdPyLog (suite)"},"content":{"rendered":"\n<p><strong style=\"color: inherit; font-size: 1.25em;\"><br \/>3. <\/strong><a href=\"https:\/\/www.ardpylab.fr\/downloads\/ardpylog\/Detecteur_de_niveau.zip\"><strong style=\"color: inherit; font-size: 1.25em;\"><span style=\"color: #3366ff;\"><u>D\u00e9tecteur de Niveau<\/u> <\/span><\/strong><\/a><span style=\"color: inherit; font-size: 1.25em; font-weight: 600;\">(<em>Contr\u00f4le de l\u2019alimentation \u00e9lectrique d\u2019une \u00e9lectrovanne<\/em> &#8211; Cat\u00e9gorie: <\/span><span style=\"color: #3366ff;\"><strong style=\"font-size: 1.25em;\">Capteurs<\/strong><\/span><span style=\"color: inherit; font-size: 1.25em; font-weight: 600;\">)<br \/><br \/><\/span><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"935\" height=\"565\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau.jpg\" alt=\"\" class=\"wp-image-6401\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau.jpg 935w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau-300x181.jpg 300w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau-768x464.jpg 768w\" sizes=\"auto, (max-width: 935px) 100vw, 935px\" \/><\/figure><\/div>\n\n\n\n<p>\u00a0<\/p>\n<p>L\u2019objectif du montage est de contr\u00f4ler l\u2019alimentation \u00e9lectrique d\u2019une \u00e9lectrovanne alimentant en eau un dispositif de d\u00e9ionisations, par l\u2019interm\u00e9diaire d\u2019un relais en fonction du niveau d\u2019eau d\u00e9tect\u00e9 par deux \u00e9lectrodes dans une bonbonne d\u2019eau d\u00e9sionis\u00e9e en sortie du dispositif.<\/p>\n<p>Apr\u00e8s avoir appuy\u00e9 sur le bouton-poussoir (DEL rouge reli\u00e9e \u00e0 la borne 13 allum\u00e9e), si les \u00e9lectrodes ne sont pas en contact avec l\u2019eau, le relais est actif, l\u2019\u00e9lectrovanne est aliment\u00e9e et est donc ouverte (DEL rouge reli\u00e9e \u00e0 la borne 7 allum\u00e9e).<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-6402\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau-1-300x185.jpg\" alt=\"\" width=\"397\" height=\"245\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau-1-300x185.jpg 300w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau-1-768x475.jpg 768w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau-1.jpg 770w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/p>\n<p>Quand les \u00e9lectrodes sont en contact avec l\u2019eau, l\u2019alimentation \u00e9lectrique de l\u2019\u00e9lectrovanne est coup\u00e9e, celle-ci est donc ferm\u00e9e (DEL rouge reli\u00e9e \u00e0 la borne 7 \u00e9teinte et DEL verte reli\u00e9e \u00e0 la borne 4 allum\u00e9e).<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-6407\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau2-300x185.jpg\" alt=\"\" width=\"398\" height=\"245\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau2-300x185.jpg 300w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau2-768x475.jpg 768w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2023\/09\/Detecteur-de-niveau2.jpg 770w\" sizes=\"auto, (max-width: 398px) 100vw, 398px\" \/><\/p>\n<p>Si la conductivit\u00e9 de l\u2019eau en contact avec les \u00e9lectrodes est bonne, la DEL bleue reli\u00e9e \u00e0 la borne 12 s\u2019allume, sinon la DEL rouge reli\u00e9e \u00e0 la borne 11 s\u2019allume.<\/p>\n<p>\u00a0<\/p>\n<p><span style=\"text-decoration: underline;\">Le programme<\/span><\/p>\n<p>Voici le code de l\u2019activit\u00e9 :<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 100%; padding-left: 40px;\">\n<p>const int switchPin = 2;<br \/>const int LedVanneOFFPin = 4;<br \/>const int LedVanneONPin=7;<br \/>const int LedGoodPin=12;<br \/>const int LedBadPin=11;<br \/>const int LedOnOffPin=13;<br \/>int const PotPin=A0;<br \/>int const RelayPin=8;<\/p>\n<p>int PotVal=0;<br \/>int switchState = 0;<br \/>int prevSwitchState = 0;<br \/>int state=0;<\/p>\n<p><br \/>void setup() {<br \/><br \/>pinMode(LedVanneOFFPin,OUTPUT);<br \/>pinMode(LedVanneONPin,OUTPUT);<br \/>pinMode(LedOnOffPin,OUTPUT);<br \/>pinMode(LedGoodPin,OUTPUT);<br \/>pinMode(LedBadPin,OUTPUT);<br \/>pinMode(switchPin,INPUT);<\/p>\n<p>Serial.begin(9600);<\/p>\n<p>}<\/p>\n<p>void loop() {<\/p>\n<p>switchState = digitalRead(switchPin);<\/p>\n<p>if ((switchState == HIGH)&amp;&amp;(prevSwitchState == LOW)) {<br \/>state=1-state;<br \/>delay(10);<br \/>}<br \/>else {<br \/>if ((switchState == LOW)&amp;&amp;(prevSwitchState == HIGH)) {<br \/>delay(10);<br \/>}<br \/>}<br \/>prevSwitchState = switchState;<br \/><br \/>if (state==1) {<\/p>\n<p>digitalWrite(LedOnOffPin, HIGH);<br \/>PotVal=analogRead(PotPin);<br \/>Serial.println(PotVal);<\/p>\n<p>if (PotVal &lt; 1015) {<br \/><br \/>digitalWrite(LedVanneONPin, LOW);<br \/>digitalWrite(LedVanneOFFPin, HIGH);<br \/>digitalWrite(RelayPin, LOW);<\/p>\n<p>if (PotVal &gt; 800) { <br \/>digitalWrite(LedGoodPin, HIGH);<br \/>digitalWrite(LedBadPin, LOW);<br \/>}<br \/>else {<br \/>digitalWrite(LedGoodPin, LOW);<br \/>digitalWrite(LedBadPin, HIGH);<br \/>}<br \/><br \/>}<\/p>\n<p><br \/>else {<br \/><br \/>digitalWrite(LedVanneONPin, HIGH);<br \/>digitalWrite(LedVanneOFFPin, LOW);<br \/>digitalWrite(LedGoodPin, LOW);<br \/>digitalWrite(RelayPin, HIGH);<\/p>\n<p>}<\/p>\n<p>delay(1000);<br \/>}<\/p>\n<p>else {<br \/>digitalWrite(LedOnOffPin, LOW);<br \/>digitalWrite(RelayPin, LOW);<br \/>digitalWrite(LedVanneONPin, LOW);<br \/>digitalWrite(LedVanneOFFPin, LOW);<br \/>digitalWrite(LedGoodPin, LOW);<br \/>digitalWrite(LedBadPin, LOW);<br \/>} <br \/>}<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00a0<\/p>\n<p><span style=\"text-decoration: underline;\">D\u00e9roulement du programme<\/span> :<\/p>\n<p>\u2013 1. D\u00e9claration des constantes et variables :<\/p>\n<p style=\"padding-left: 40px;\">. <strong>const int switchPin = 2<\/strong> (constante nombre entier correspondant \u00e0 la broche du bouton poussoir)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>const int LedVanneOFFPin = 4<\/strong> (constante nombre entier correspondant \u00e0 la broche de la DEL verte indiquant que l\u2019\u00e9lectrovanne est ferm\u00e9e)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>const int LedVanneONPin=7<\/strong> (constante nombre entier correspondant \u00e0 la broche de la DEL rouge indiquant que l\u2019\u00e9lectrovanne est ouverte)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>const int LedGoodPin=12<\/strong> (constante nombre entier correspondant \u00e0 la broche de la DEL bleue indiquant que la conductivit\u00e9 de l\u2019eau est bonne)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>const int LedBadPin=11<\/strong> (constante nombre entier correspondant \u00e0 la broche de la DEL rouge indiquant que la conductivit\u00e9 de l\u2019eau n\u2019est pas bonne)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>const int LedOnOffPin=13<\/strong> (constante nombre entier correspondant \u00e0 la broche de la DEL rouge indiquant que le d\u00e9tecteur de niveau fonctionne)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>int const PotPin=A0<\/strong> (constante nombre entier correspondant \u00e0 la broche de l\u2019\u00e9lectrode de mesure)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>int const RelayPin=8<\/strong> (constante nombre entier correspondant \u00e0 la broche de commande du relais)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>int PotVal=0<\/strong> (variable nombre entier pour stocker la valeur du potentiel de l\u2019\u00e9lectrode de mesure)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>int switchState = 0<\/strong> (variable nombre entier pour stocker la valeur du potentiel de la broche du bouton poussoir)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>int prevSwitchState = 0<\/strong> (variable nombre entier pour stocker l\u2019ancienne valeur du potentiel de la broche du bouton poussoir)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>int state=0<\/strong> (variable nombre entier correspondant \u00e0 l\u2019action \u00e0 effectuer)<\/p>\n<p><br \/>\u2013 2. Initialisation des entr\u00e9es et sorties :<\/p>\n<p style=\"padding-left: 40px;\">. <strong>Initialisation des entr\u00e9es et des sorties (DELs, bouton poussoirs)<\/strong><\/p>\n<p style=\"padding-left: 40px;\">.<strong> Initialisation de la liaison s\u00e9rie \u00e0 un d\u00e9bit de 9600 bauds<\/strong><\/p>\n<p><br \/>\u2013 3. Fonction principale en boucle :<\/p>\n<p style=\"padding-left: 40px;\">\u2013&gt; <strong>Lecture de la valeur de la broche du bouton poussoir,<\/strong><\/p>\n<p style=\"padding-left: 40px;\">\u2013&gt; <strong>Mise \u00e0 jour de la variable \u00ab state \u00bb si changement de la valeur du bouton poussoir,<\/strong><\/p>\n<p style=\"padding-left: 40px;\">\u2013&gt; <strong>Mise en route ou arr\u00eat du dispositif en fonction de la variable \u00ab state \u00bb,<\/strong><\/p>\n<p style=\"padding-left: 40px;\">&#8211;&gt; <strong>Lecture du potentiel de l\u2019\u00e9lectrode (affichage de la valeur dans le moniteur s\u00e9rie),<\/strong><\/p>\n<p style=\"padding-left: 40px;\">&#8211;&gt; <strong>Fermeture ou ouverture de la vanne d\u2019alimentation en eau en fonction de la valeur du potentiel de l\u2019\u00e9lectrode, puis indication sur la qualit\u00e9 de la conductivit\u00e9 de l\u2019eau.<\/strong><\/p>\n<p>\u00a0<\/p>\n\n\n<div  class=\"grids-section grids-is-advanced\" style=\"--_gs-gap-desktop:0px 0px;--_gs-m-desktop:0 0 0 0;--_gs-p-desktop:0 0 0 0;--_gs-bg-desktop:transparent none;--_gs-bg-xp-desktop:0px;--_gs-zi-desktop:auto;--_gs-d-desktop:block;--_gs-mw-desktop:calc(100% - 0 - 0);--_gs-gap-tablet:0px 0px;--_gs-m-tablet:0 0 0 0;--_gs-p-tablet:0 0 0 0;--_gs-bg-tablet:transparent none;--_gs-bg-xp-tablet:0px;--_gs-zi-tablet:auto;--_gs-d-tablet:block;--_gs-mw-tablet:calc(100% - 0 - 0);--_gs-gap-mobile:0px 0px;--_gs-m-mobile:0 0 0 0;--_gs-p-mobile:0 0 0 0;--_gs-bg-mobile:transparent none;--_gs-bg-xp-mobile:0px;--_gs-zi-mobile:auto;--_gs-d-mobile:block;--_gs-mw-mobile:calc(100% - 0 - 0);--_gs-columns:12;--_gs-rows:6\"><div class=\"grids-s-w_i\">\n<div class=\"grids-area\" style=\"--_ga-column:1\/2;--_ga-row:1\/2;--_ga-m-desktop:0 0 0 0;--_ga-p-desktop:0 0 0 0;--_ga-bg-desktop:transparent none;--_ga-zi-desktop:auto;--_ga-d-desktop:flex;--_ga-mw-desktop:calc(100% - 0 - 0);--_ga-m-tablet:0 0 0 0;--_ga-p-tablet:0 0 0 0;--_ga-bg-tablet:transparent none;--_ga-zi-tablet:auto;--_ga-d-tablet:flex;--_ga-mw-tablet:calc(100% - 0 - 0);--_ga-m-mobile:0 0 0 0;--_ga-p-mobile:0 0 0 0;--_ga-bg-mobile:transparent none;--_ga-zi-mobile:auto;--_ga-d-mobile:flex;--_ga-mw-mobile:calc(100% - 0 - 0)\">\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/www.ardpylab.fr\/?page_id=6375\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/03\/moins.jpg\" alt=\"\" class=\"wp-image-107\" width=\"44\" height=\"24\"\/><\/a><\/figure>\n\n<\/div>\n\n<div class=\"grids-area\" style=\"--_ga-column:12\/13;--_ga-row:1\/2;--_ga-m-desktop:0 0 0 0;--_ga-p-desktop:0 0 0 0;--_ga-bg-desktop:transparent none;--_ga-zi-desktop:auto;--_ga-d-desktop:flex;--_ga-mw-desktop:calc(100% - 0 - 0);--_ga-m-tablet:0 0 0 0;--_ga-p-tablet:0 0 0 0;--_ga-bg-tablet:transparent none;--_ga-zi-tablet:auto;--_ga-d-tablet:flex;--_ga-mw-tablet:calc(100% - 0 - 0);--_ga-m-mobile:0 0 0 0;--_ga-p-mobile:0 0 0 0;--_ga-bg-mobile:transparent none;--_ga-zi-mobile:auto;--_ga-d-mobile:flex;--_ga-mw-mobile:calc(100% - 0 - 0)\">\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.ardpylab.fr\/?page_id=6436\"><img loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"28\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/03\/plus.jpg\" alt=\"\" class=\"wp-image-106\"\/><\/a><\/figure>\n\n<\/div>\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>3. D\u00e9tecteur de Niveau (Contr\u00f4le de l\u2019alimentation \u00e9lectrique d\u2019une \u00e9lectrovanne &#8211; Cat\u00e9gorie: Capteurs) \u00a0 L\u2019objectif du montage est de contr\u00f4ler l\u2019alimentation \u00e9lectrique d\u2019une \u00e9lectrovanne alimentant en eau un dispositif de d\u00e9ionisations, par l\u2019interm\u00e9diaire d\u2019un relais en fonction du niveau d\u2019eau d\u00e9tect\u00e9 par deux \u00e9lectrodes dans une bonbonne d\u2019eau d\u00e9sionis\u00e9e en sortie du dispositif. Apr\u00e8s avoir [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6399","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/6399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6399"}],"version-history":[{"count":13,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/6399\/revisions"}],"predecessor-version":[{"id":6468,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/6399\/revisions\/6468"}],"wp:attachment":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}