{"id":3434,"date":"2020-04-25T10:42:11","date_gmt":"2020-04-25T08:42:11","guid":{"rendered":"http:\/\/www.ardpylab.fr\/?page_id=3434"},"modified":"2020-05-10T18:01:39","modified_gmt":"2020-05-10T16:01:39","slug":"projet-3-activite-1","status":"publish","type":"page","link":"https:\/\/www.ardpylab.fr\/?page_id=3434","title":{"rendered":"Projet 3 &#8211; Activit\u00e9 1"},"content":{"rendered":"\n<h2 style=\"text-align: center;\"><strong><em>\u201dFaire clignoter une DEL et produire <br><\/em><\/strong><strong><em>un \u00ab\u00a0beep\u00a0\u00bb synchrone\u201d<u><\/u><\/em><\/strong><\/h2>\n<p>&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"549\" height=\"334\" class=\"wp-image-3579 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-circuit5.png\" alt=\"\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-circuit5.png 549w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-circuit5-300x183.png 300w\" sizes=\"auto, (max-width: 549px) 100vw, 549px\" \/><\/figure>\n<\/div>\n\n\n\n<p>&nbsp;<\/p>\n<h4><strong><span style=\"color: #3366ff;\">.&nbsp;<span style=\"text-decoration: underline;\">Objectif<\/span><\/span><\/strong><\/h4>\n<p><br>Dans cette activit\u00e9, nous allons voir qu&rsquo;il est possible d&rsquo;\u00e9mettre un son avec un Arduino et modifier le premier programme qui permet de faire clignoter une DEL, pour commander la production d&rsquo;un signal sonore (\u00ab\u00a0un beep\u00a0\u00bb), \u00e9mis par un piezo ou un petit haut-parleur, synchrone avec le clignotement de la diode.<\/p>\n<p>Le code en Python ou en langage Arduino pourra \u00eatre modifi\u00e9 pour voir l\u2019influence des variables (fr\u00e9quence de l\u2019onde sonore, dur\u00e9e d\u2019\u00e9mission, dur\u00e9e de silence).<\/p>\n<h4>&nbsp;<\/h4>\n<h4><strong><span style=\"color: #3366ff;\">.&nbsp;<span style=\"text-decoration: underline;\">Le programme<br><br><\/span><\/span><\/strong><\/h4>\n\n\n\n<h4><strong><span style=\"color: #0000ff;\"><span style=\"color: #000000;\"><a id=\"prog1\"><\/a>. <\/span><span style=\"color: #000000;\">Programme en Python<\/span> <span style=\"color: #000000;\">(\u201d<\/span><a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet3\/projet3-activity1.zip\" data-wplink-url-error=\"true\">Projet3\/Activity1\/PY\/Activity1.py<\/a>\u201d<span style=\"color: #000000;\">)<\/span><\/span><\/strong><\/h4>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet3\/Activity1\/PY\/Activity1.py\" data-wplink-url-error=\"true\"><img loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"926\" class=\"wp-image-3461 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-2.png\" alt=\"\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-2.png 896w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-2-290x300.png 290w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-2-768x794.png 768w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<p><strong><u><br>D\u00e9roulement du programme<\/u><\/strong><strong>&nbsp;:<\/strong><\/p>\n<p>&#8211; <u>Importation des librairies&nbsp;et d\u00e9finition de fonctions<\/u> :<\/p>\n<p style=\"padding-left: 40px;\">. Le module <strong>\u201dConnectToArduino.py\u201d, <\/strong>contenant les fonctions de connexion \u00e0 l\u2019Arduino via le protocole <strong>\u201dFirmata Express\u201d<\/strong>,<\/p>\n<p style=\"padding-left: 40px;\">. Le module <strong>\u201d<\/strong><strong>PymataExpressDef.Py\u201d<\/strong> regroupant toutes les fonctions utiles \u00e0 l\u2019utilisation de <strong>\u201d<\/strong><strong>Pymata<\/strong><strong>-express\u201d<\/strong>&nbsp;(fonction de d\u00e9claration des entr\u00e9es et sorties, de lectures, d\u2019\u00e9critures\u2026) ,<\/p>\n<p style=\"padding-left: 40px;\">. La biblioth\u00e8que <strong>\u201d<\/strong><strong>time\u201d <\/strong>pour la gestion des temps de pause.<br><br><\/p>\n<p>&#8211; <u>D\u00e9claration des constantes et variables<\/u>&nbsp;:<\/p>\n<p style=\"padding-left: 40px;\">. <strong>PinLED = 4<\/strong> (constante correspondant au n\u00b0 de la broche sur laquelle la DEL rouge est connect\u00e9e)<\/p>\n<p style=\"padding-left: 40px;\"><strong>. PinTone = 3<\/strong> (constante correspondant au n\u00b0 de la broche sur laquelle le buzzer est connect\u00e9)<\/p>\n<p style=\"padding-left: 40px;\"><strong>. FreqTone = 440<\/strong> (constante correspondant \u00e0 la fr\u00e9quence de l\u2019onde sonore)<\/p>\n<p style=\"padding-left: 40px;\"><strong>. TimeSleep1 = 0.5<\/strong> (cst correspondant \u00e0 la dur\u00e9e en s de l\u2019\u00e9mission sonore et d\u2019allumage de la DEL)<\/p>\n<p style=\"padding-left: 40px;\"><strong>. TimeSleep2 = 0.5<\/strong> (cst correspondant \u00e0 la dur\u00e9e en s du silence et de l\u2019extinction de la DEL)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>PortComArduino <\/strong>(port COM sur lequel l\u2019Arduino est connect\u00e9)<br><br><\/p>\n<p>&#8211; <u>Connexion \u00e0 l&rsquo;Arduino<\/u> :<\/p>\n<p style=\"padding-left: 40px;\">. D\u00e9tection du port COM, tentative d\u2019ouverture du port COM s\u00e9lectionn\u00e9 et connexion \u00e0 l\u2019Arduino:<\/p>\n<p style=\"padding-left: 80px;\"><strong>PortComArduino = SelectPortCOM()<\/strong><\/p>\n<p style=\"padding-left: 80px;\"><strong>board = OpenPortCom(PortComArduino)<br><br><\/strong><\/p>\n<p style=\"padding-left: 40px;\">. Si la connexion \u00e0 l\u2019Arduino est r\u00e9ussie :<\/p>\n<p style=\"padding-left: 80px;\">&#8211; D\u00e9claration de la broche du buzzer en mode \u201dTone\u201d&nbsp;:<\/p>\n<p style=\"padding-left: 120px;\"><strong>Set_Tone_Pin(board, PinTone)<\/strong><\/p>\n<p style=\"padding-left: 80px;\">&#8211; D\u00e9claration de la broche de la DEL en sortie digitale&nbsp;:<\/p>\n<p style=\"padding-left: 120px;\"><strong>Set_DigitalOutput_Pin(board, PinLED)<br><br><\/strong><\/p>\n<p>&#8211; <u>Boucle principale du programme (boucle \u201d<\/u><u>while True\u201d<\/u><u>)<\/u> :<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"921\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-1-1024x921.png\" alt=\"\" class=\"wp-image-3462\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-1-1024x921.png 1024w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-1-300x270.png 300w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-1-768x691.png 768w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-1-1536x1381.png 1536w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-1-2048x1841.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<h4>\u00a0<\/h4>\n<h4><strong><span style=\"color: #0000ff;\"><span style=\"color: #000000;\"><a id=\"prog2\"><\/a>. Programme en langage Arduino (\u201d<\/span><a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet3\/projet3-activity1.zip\" data-wplink-url-error=\"true\">Projet3\/Activity1\/INO\/Activity1.ino<\/a>\u201d<span style=\"color: #000000;\">)<\/span><\/span><\/strong><\/h4>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet3\/Activity1\/INO\/Activity1\/Activity1.ino\" data-wplink-url-error=\"true\"><img loading=\"lazy\" decoding=\"async\" width=\"765\" height=\"637\" class=\"wp-image-3463 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-3.png\" alt=\"\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-3.png 765w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-3-300x250.png 300w\" sizes=\"auto, (max-width: 765px) 100vw, 765px\" \/><\/a><\/figure>\n<\/div>\n<p><strong><u>D\u00e9roulement du programme<\/u><\/strong><strong>\u00a0:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"1024\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-4-890x1024.png\" alt=\"\" class=\"wp-image-3464\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-4-890x1024.png 890w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-4-261x300.png 261w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-4-768x884.png 768w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-4-1335x1536.png 1335w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity1-4-1780x2048.png 1780w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/figure><\/div>\n\n\n<div  class=\"grids-section grids-is-stretch\" 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:2;--_gs-rows:1\"><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<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><a href=\"https:\/\/www.ardpylab.fr\/?page_id=3436\"><img loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"28\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/03\/moins.jpg\" alt=\"\" class=\"wp-image-107\"\/><\/a><\/figure><\/div>\n\n<\/div>\n\n<div class=\"grids-area\" style=\"--_ga-column:2\/3;--_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<div class=\"wp-block-image\"><figure class=\"alignright size-large\"><a href=\"https:\/\/www.ardpylab.fr\/?page_id=3476\"><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><\/div>\n\n<\/div>\n<\/div><\/div>\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>\u201dFaire clignoter une DEL et produire un \u00ab\u00a0beep\u00a0\u00bb synchrone\u201d &nbsp; &nbsp; .&nbsp;Objectif Dans cette activit\u00e9, nous allons voir qu&rsquo;il est possible d&rsquo;\u00e9mettre un son avec un Arduino et modifier le premier programme qui permet de faire clignoter une DEL, pour commander la production d&rsquo;un signal sonore (\u00ab\u00a0un beep\u00a0\u00bb), \u00e9mis par un piezo ou un petit [&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-3434","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/3434","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=3434"}],"version-history":[{"count":0,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/3434\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}