{"id":3269,"date":"2022-10-11T15:34:39","date_gmt":"2022-10-11T13:34:39","guid":{"rendered":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led\/programmer-une-led-rgb\/"},"modified":"2022-10-13T15:59:15","modified_gmt":"2022-10-13T13:59:15","slug":"programmer-une-led-rgb","status":"publish","type":"page","link":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/","title":{"rendered":"Programmer une LED RGB"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Le montage<\/h3>\n\n\n\n<p>R : GP14 :<\/p>\n\n\n\n<p>Com : GND<\/p>\n\n\n\n<p>G : GP13<\/p>\n\n\n\n<p>B : GP12<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"516\" height=\"435\" src=\"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png\" alt=\"\" class=\"wp-image-3317\" srcset=\"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png 516w, https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico-300x253.png 300w\" sizes=\"auto, (max-width: 516px) 100vw, 516px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Avec Picozero<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\"\"\"\nLED RGB\nR sur GP14\nG sur GP13\nB sur GP12'''  '''\n\"\"\"\n\nfrom picozero import RGBLED\nfrom time import sleep\n\nrgb = RGBLED(red = 14, green = 13, blue = 12)\n\nrgb.blink(on_times=(1,0.5,2), colors=((255,0,0),(0,255,0),(0,0,255)), wait=True, n=3)\nrgb.off()\n\n# for k in range(3):\n#     rgb.color = (255, 0, 0)\n#     sleep(1)\n#     rgb.color = (0, 255, 0)\n#     sleep(0.5)\n#     rgb.color = (0, 0, 255)\n#     sleep(2)\n# rgb.off()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Sans Picozero<\/h3>\n\n\n\n<p>Il faut transformer les pattes en PWM.<\/p>\n\n\n\n<p>Pour simplifier l&rsquo;\u00e9criture des niveaux de couleurs, on peut se servir d&rsquo;une classe.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from machine import Pin,PWM\nfrom time import sleep\n\nclass ledPWM(PWM):\n    def __init__(self, pin: Pin):\n        super().__init__(pin)\n    def color(self,val):\n        super().duty_u16(65535*val\/\/255)\n        \ndef changer_couleurs(cols):\n    led_red.color(cols[0])\n    led_green.color(cols[1])\n    led_blue.color(cols[2])\n\nled_red = ledPWM(Pin(14))\nled_green = ledPWM(Pin(13))\nled_blue = ledPWM(Pin(12))\n\n\nfor k in range(3):\n    changer_couleurs((80,120,0))\n    sleep(0.5)\n    changer_couleurs((100,0,120))               \n    sleep(0.5)\n    changer_couleurs((0,150,255))               \n    sleep(0.5)\n    \nled_red.color(0)\nled_green.color(0)\nled_blue.color(0)\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Le montage R : GP14 : Com : GND G : GP13 B : GP12 Avec Picozero Sans Picozero Il faut transformer les pattes en PWM. Pour simplifier l&rsquo;\u00e9criture des&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3260,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3269","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Programmer une LED RGB - Maths &amp; Num\u00e9rique<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Programmer une LED RGB - Maths &amp; Num\u00e9rique\" \/>\n<meta property=\"og:description\" content=\"Le montage R : GP14 : Com : GND G : GP13 B : GP12 Avec Picozero Sans Picozero Il faut transformer les pattes en PWM. Pour simplifier l&rsquo;\u00e9criture des&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/\" \/>\n<meta property=\"og:site_name\" content=\"Maths &amp; Num\u00e9rique\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-13T13:59:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/\",\"url\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/\",\"name\":\"Programmer une LED RGB - Maths &amp; Num\u00e9rique\",\"isPartOf\":{\"@id\":\"https:\/\/wordpress.callac.online\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png\",\"datePublished\":\"2022-10-11T13:34:39+00:00\",\"dateModified\":\"2022-10-13T13:59:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#primaryimage\",\"url\":\"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png\",\"contentUrl\":\"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png\",\"width\":516,\"height\":435},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/wordpress.callac.online\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/wordpress.callac.online\/index.php\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Raspberry Pi Pico et MicroPython\",\"item\":\"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Programmer une LED RGB\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wordpress.callac.online\/#website\",\"url\":\"https:\/\/wordpress.callac.online\/\",\"name\":\"Maths & Num\u00e9rique\",\"description\":\"Des outils pour les enseignants de math\u00e9matiques et de num\u00e9rique\",\"publisher\":{\"@id\":\"https:\/\/wordpress.callac.online\/#\/schema\/person\/04061f1ca2c2c42039142a704be95940\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wordpress.callac.online\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/wordpress.callac.online\/#\/schema\/person\/04061f1ca2c2c42039142a704be95940\",\"name\":\"dlefur\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/wordpress.callac.online\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4a9e17be136808c6597f28aa2b6c13126dab066fdc2198ff60090972c9b7fafc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4a9e17be136808c6597f28aa2b6c13126dab066fdc2198ff60090972c9b7fafc?s=96&d=mm&r=g\",\"caption\":\"dlefur\"},\"logo\":{\"@id\":\"https:\/\/wordpress.callac.online\/#\/schema\/person\/image\/\"},\"description\":\"Enseignant de math\u00e9matiques Lyc\u00e9e Pasteur S\u00e3o Paulo\",\"sameAs\":[\"http:\/\/wordpress.callac.online\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Programmer une LED RGB - Maths &amp; Num\u00e9rique","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/","og_locale":"fr_FR","og_type":"article","og_title":"Programmer une LED RGB - Maths &amp; Num\u00e9rique","og_description":"Le montage R : GP14 : Com : GND G : GP13 B : GP12 Avec Picozero Sans Picozero Il faut transformer les pattes en PWM. Pour simplifier l&rsquo;\u00e9criture des&hellip;","og_url":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/","og_site_name":"Maths &amp; Num\u00e9rique","article_modified_time":"2022-10-13T13:59:15+00:00","og_image":[{"url":"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/","url":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/","name":"Programmer une LED RGB - Maths &amp; Num\u00e9rique","isPartOf":{"@id":"https:\/\/wordpress.callac.online\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#primaryimage"},"image":{"@id":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#primaryimage"},"thumbnailUrl":"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png","datePublished":"2022-10-11T13:34:39+00:00","dateModified":"2022-10-13T13:59:15+00:00","breadcrumb":{"@id":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#primaryimage","url":"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png","contentUrl":"https:\/\/wordpress.callac.online\/wp-content\/uploads\/2022\/10\/rgb-pico.png","width":516,"height":435},{"@type":"BreadcrumbList","@id":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/programmer-une-led-rgb\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/wordpress.callac.online\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/wordpress.callac.online\/index.php\/python\/"},{"@type":"ListItem","position":3,"name":"Raspberry Pi Pico et MicroPython","item":"https:\/\/wordpress.callac.online\/index.php\/python\/raspberry-pi-pico-et-micropython\/"},{"@type":"ListItem","position":4,"name":"Programmer une LED RGB"}]},{"@type":"WebSite","@id":"https:\/\/wordpress.callac.online\/#website","url":"https:\/\/wordpress.callac.online\/","name":"Maths & Num\u00e9rique","description":"Des outils pour les enseignants de math\u00e9matiques et de num\u00e9rique","publisher":{"@id":"https:\/\/wordpress.callac.online\/#\/schema\/person\/04061f1ca2c2c42039142a704be95940"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wordpress.callac.online\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":["Person","Organization"],"@id":"https:\/\/wordpress.callac.online\/#\/schema\/person\/04061f1ca2c2c42039142a704be95940","name":"dlefur","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/wordpress.callac.online\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4a9e17be136808c6597f28aa2b6c13126dab066fdc2198ff60090972c9b7fafc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4a9e17be136808c6597f28aa2b6c13126dab066fdc2198ff60090972c9b7fafc?s=96&d=mm&r=g","caption":"dlefur"},"logo":{"@id":"https:\/\/wordpress.callac.online\/#\/schema\/person\/image\/"},"description":"Enseignant de math\u00e9matiques Lyc\u00e9e Pasteur S\u00e3o Paulo","sameAs":["http:\/\/wordpress.callac.online"]}]}},"_links":{"self":[{"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/pages\/3269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/comments?post=3269"}],"version-history":[{"count":4,"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/pages\/3269\/revisions"}],"predecessor-version":[{"id":3321,"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/pages\/3269\/revisions\/3321"}],"up":[{"embeddable":true,"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/pages\/3260"}],"wp:attachment":[{"href":"https:\/\/wordpress.callac.online\/index.php\/wp-json\/wp\/v2\/media?parent=3269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}