{"id":3492,"date":"2020-04-25T15:27:23","date_gmt":"2020-04-25T13:27:23","guid":{"rendered":"http:\/\/www.ardpylab.fr\/?page_id=3492"},"modified":"2020-05-10T18:05:13","modified_gmt":"2020-05-10T16:05:13","slug":"projet-3-activite-3","status":"publish","type":"page","link":"https:\/\/www.ardpylab.fr\/?page_id=3492","title":{"rendered":"Projet 3 &#8211; Activit\u00e9 3"},"content":{"rendered":"\n<h2 style=\"text-align: center;\"><strong><em>\u201dEmettre une onde sonore avec <br>un bouton-poussoir<\/em><\/strong><strong><em>\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\" class=\"wp-image-3573 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-circuit7.png\" alt=\"\" width=\"441\" height=\"370\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-circuit7.png 480w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-circuit7-300x251.png 300w\" sizes=\"auto, (max-width: 441px) 100vw, 441px\" \/><\/figure>\n<\/div>\n<p>&nbsp;<\/p>\n\n\n\n<h4>&nbsp;<\/h4>\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 commander la production d&rsquo;une onde sonore de fr\u00e9quence pr\u00e9alablement choisie en appuyant sur le premier bouton poussoir. L&rsquo;\u00e9mission est arr\u00eat\u00e9e en rel\u00e2chant le bouton poussoir.<\/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&rsquo;onde sonore en Hz).<\/p>\n<p>&nbsp;<\/p>\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-activity3.zip\" data-wplink-url-error=\"true\">Projet3\/Activity3\/PY\/Activity3.py<\/a><span style=\"color: #000000;\">\u201d)<br \/><br \/><\/span><\/span><\/strong><\/h4>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet3\/Activity3\/PY\/Activity3.py\" data-wplink-url-error=\"true\"><img loading=\"lazy\" decoding=\"async\" width=\"897\" height=\"865\" class=\"wp-image-3493 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-1.png\" alt=\"\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-1.png 897w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-1-300x289.png 300w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-1-768x741.png 768w\" sizes=\"auto, (max-width: 897px) 100vw, 897px\" \/><\/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>. 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>PinButton = 12 <\/strong>(constante correspondant au n\u00b0 de la broche sur laquelle le bouton poussoir est connect\u00e9)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>ValButton = 0<\/strong> (variable pour stocker la valeur de l\u2019\u00e9tat logique de la broche du bouton poussoir)<\/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 du bouton poussoir en entr\u00e9e digitale&nbsp;:<\/p>\n<p style=\"padding-left: 120px;\"><strong>Set_DigitalInput_Pin(board, PinButton)<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<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1019\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-2-1-1024x1019.png\" alt=\"\" class=\"wp-image-3505\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-2-1-1024x1019.png 1024w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-2-1-300x300.png 300w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-2-1-150x150.png 150w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-2-1-768x764.png 768w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-2-1-1536x1529.png 1536w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-2-1-2048x2038.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\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-activity3.zip\" data-wplink-url-error=\"true\">Projet3\/Activity3\/INO\/Activity3.ino<\/a><span style=\"color: #000000;\">\u201d)<\/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\/Activity3\/INO\/Activity3\/Activity3.ino\" data-wplink-url-error=\"true\"><img loading=\"lazy\" decoding=\"async\" width=\"761\" height=\"642\" class=\"wp-image-3496 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-3.png\" alt=\"\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-3.png 761w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-3-300x253.png 300w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/><\/a><\/figure>\n<\/div>\n<p><strong><u>D\u00e9roulement du programme<\/u><\/strong><strong>\u00a0:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-4-1-884x1024.png\" alt=\"\" class=\"wp-image-3502\" width=\"878\" height=\"1016\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-4-1-884x1024.png 884w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-4-1-259x300.png 259w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-4-1-768x890.png 768w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-4-1-1326x1536.png 1326w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/04\/projet3-activity3-4-1-1768x2048.png 1768w\" sizes=\"auto, (max-width: 878px) 100vw, 878px\" \/><\/figure>\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=3476\"><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=3514\"><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>\u201dEmettre une onde sonore avec un bouton-poussoir\u201d &nbsp; &nbsp; &nbsp; .&nbsp;Objectif Dans cette activit\u00e9, nous allons commander la production d&rsquo;une onde sonore de fr\u00e9quence pr\u00e9alablement choisie en appuyant sur le premier bouton poussoir. L&rsquo;\u00e9mission est arr\u00eat\u00e9e en rel\u00e2chant le bouton poussoir. Le code en Python ou en langage Arduino pourra \u00eatre modifi\u00e9 pour voir l\u2019influence [&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-3492","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/3492","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=3492"}],"version-history":[{"count":0,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/3492\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}