{"id":1330,"date":"2021-12-13T22:56:58","date_gmt":"2021-12-13T13:56:58","guid":{"rendered":"https:\/\/okamoto3.com\/?p=1330"},"modified":"2023-03-01T16:54:21","modified_gmt":"2023-03-01T07:54:21","slug":"freenove-gpiozero-python3","status":"publish","type":"post","link":"https:\/\/okamoto3.com\/index.php\/2021\/12\/13\/freenove-gpiozero-python3\/1330\/","title":{"rendered":"Freenove Raspberry pi \u30b9\u30bf\u30fc\u30bf\u30fc\u30ad\u30c3\u30c8 LED bar\u30c1\u30ab gpiozero Python3"},"content":{"rendered":"<p><center><br \/>\n<iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"https:\/\/rcm-fe.amazon-adsystem.com\/e\/cm?ref=tf_til&amp;t=shigeki3-22&amp;m=amazon&amp;o=9&amp;p=8&amp;l=as1&amp;IS1=1&amp;detail=1&amp;asins=B06WD5FTVD&amp;linkId=30ca1330dc4dd3e647117aae17c065c1&amp;bc1=ffffff&amp;lt1=_top&amp;fc1=333333&amp;lc1=0066c0&amp;bg1=ffffff&amp;f=ifr\"><br \/>\n    <\/iframe><br \/>\n<\/center><\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/amzn.to\/3ydLVVl\">\u30a2\u30de\u30be\u30f3\u3067\u898b\u308b<\/a><\/p><figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"436\" height=\"1024\" src=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/IMG_20211212_134206-01_copy_531x1246.jpeg?resize=436%2C1024&#038;ssl=1\" alt=\"\" class=\"wp-image-1349\" srcset=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/IMG_20211212_134206-01_copy_531x1246.jpeg?resize=436%2C1024&amp;ssl=1 436w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/IMG_20211212_134206-01_copy_531x1246.jpeg?resize=128%2C300&amp;ssl=1 128w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/IMG_20211212_134206-01_copy_531x1246.jpeg?w=531&amp;ssl=1 531w\" sizes=\"auto, (max-width: 436px) 100vw, 436px\" \/><figcaption class=\"wp-element-caption\">\u3056\u3063\u304f\u308a\u306e\u914d\u7f6e<\/figcaption><\/figure><h2 class=\"wp-block-heading\">\u914d\u7dda<\/h2><figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"378\" src=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/led-bar_E38396E383ACE38383E38389E3839CE383BCE38389_copy_1417x714.jpg?resize=750%2C378&#038;ssl=1\" alt=\"\" class=\"wp-image-1368\" srcset=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/led-bar_E38396E383ACE38383E38389E3839CE383BCE38389_copy_1417x714.jpg?resize=1024%2C516&amp;ssl=1 1024w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/led-bar_E38396E383ACE38383E38389E3839CE383BCE38389_copy_1417x714.jpg?resize=300%2C151&amp;ssl=1 300w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/led-bar_E38396E383ACE38383E38389E3839CE383BCE38389_copy_1417x714.jpg?resize=768%2C387&amp;ssl=1 768w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/led-bar_E38396E383ACE38383E38389E3839CE383BCE38389_copy_1417x714.jpg?resize=600%2C302&amp;ssl=1 600w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/led-bar_E38396E383ACE38383E38389E3839CE383BCE38389_copy_1417x714.jpg?w=1417&amp;ssl=1 1417w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\">GPIO<\/figcaption><\/figure><p>LEDbar(27, 22, 5, 6,13, 19, 26, 21, 20, 16)<br \/>\u8d64led (18)<br \/>\u7dd1led (23)<\/p><p>\u524dbutton(4, hold_time=0.5)<br \/>\u5f8cbutton (12, hold_time=0.5)<\/p><h2 class=\"wp-block-heading\">\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2><figure class=\"wp-block-embed is-type-wp-embed is-provider-sgg-039-s wp-block-embed-sgg-039-s\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"4WkvW8Qd2Q\"><a href=\"https:\/\/okamoto3.com\/index.php\/2021\/12\/07\/raspberry-pi-os-power-sw\/1253\/\">Raspberry pi OS \u96fb\u6e90\u30b9\u30a4\u30c3\u30c1\u53d6\u4ed8 \u306f\u3093\u3060\u4ed8\u3051\u7121\u3057 gpiozero Python3 systemd<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Raspberry pi OS \u96fb\u6e90\u30b9\u30a4\u30c3\u30c1\u53d6\u4ed8 \u306f\u3093\u3060\u4ed8\u3051\u7121\u3057 gpiozero Python3 systemd&#8221; &#8212; sGG&#039;s\" src=\"https:\/\/okamoto3.com\/index.php\/2021\/12\/07\/raspberry-pi-os-power-sw\/1253\/embed\/#?secret=4WkvW8Qd2Q\" data-secret=\"4WkvW8Qd2Q\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">shutdown\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u5225\u8a18\u4e8b\u3067\u3059<\/figcaption><\/figure><p>\u308f\u3057\u306f\u3001\/home\/pi\/projects\/led_bar\u306b\u4f5c\u3063\u305f\u3002<\/p><ul class=\"wp-block-list\"><li><strong>cd \/home\/pi\/projects<\/strong><\/li>\n\n<li><strong>mkdir led_bar<\/strong><\/li>\n\n<li><strong>cd led_bar<\/strong><\/li>\n\n<li><strong>nano flow.py<\/strong><\/li><\/ul><pre class=\"wp-block-preformatted\">from gpiozero import LEDBoard<br>from gpiozero import LED<br>from time import sleep<br>from signal import pause<br>from gpiozero import Button<br><br>def fw():<br>\u00a0\u00a0\u00a0 for led in leds:<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fw_p()<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sleep(0.2)<br><br>def rv():<br>\u00a0\u00a0\u00a0 for led in reversed(leds):<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rv_p()<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sleep(0.2)<br><br>def fw_p():<br>\u00a0\u00a0 global led_p<br>\u00a0\u00a0 g_led.on()<br>\u00a0\u00a0 r_led.off()<br>\u00a0\u00a0 led = leds[led_p]<br>\u00a0\u00a0 led.off()<br>\u00a0\u00a0 led_p = led_p + 1<br>\u00a0\u00a0 if led_p &gt; len(leds)-1:<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 led_p = 0<br>\u00a0\u00a0 led = leds[led_p]<br>\u00a0\u00a0 led.on()<br><br>def rv_p():<br>\u00a0\u00a0 global led_p<br>\u00a0\u00a0 r_led.on()<br>\u00a0\u00a0 g_led.off()<br>\u00a0\u00a0 led = leds[led_p]<br>\u00a0\u00a0 led.off()<br>\u00a0\u00a0 led_p = led_p - 1<br>\u00a0\u00a0 if led_p &lt; 0:<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 led_p = len(leds)-1<br>\u00a0\u00a0 led = leds[led_p]<br>\u00a0\u00a0 led.on()<br><br><br>leds = LEDBoard(27, 22, 5, 6,13, 19, 26, 21, 20, 16)<br>r_led = LED(18)<br>g_led = LED(23)<br><br>fw_button = Button(4, hold_time=0.5)<br>rv_button = Button(12, hold_time=0.5)<br><br>led_p = 0<br>led = leds[led_p]<br>led.on()<br><br>fw_button.when_held = fw<br>rv_button.when_held = rv<br>fw_button.when_pressed = fw_p<br>rv_button.when_pressed = rv_p<br><br>pause()<br><\/pre><p>ctrl+z\u3067\u4fdd\u5b58<\/p><h2 class=\"wp-block-heading\">\u5b9f\u884c<\/h2><ul class=\"wp-block-list\"><li><strong>python3 flow.py<\/strong><\/li><\/ul><h2 class=\"wp-block-heading\"><strong>\u505c\u6b62<\/strong><\/h2><p>ctrl+c<\/p><h2 class=\"wp-block-heading\">\u52d5\u4f5c\u306e\u69d8\u5b50<\/h2><figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Freenove Raspberry pi \u30b9\u30bf\u30fc\u30bf\u30fc\u30ad\u30c3\u30c8 LED bar\u30c1\u30ab gpiozero Python3\" width=\"750\" height=\"422\" src=\"https:\/\/www.youtube.com\/embed\/Zf_zaZOF3v4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure><p>\u4ee5\u4e0a\uff01<\/p><hr class=\"wp-block-separator has-css-opacity\"\/><figure class=\"wp-block-embed is-type-wp-embed is-provider-sgg-039-s wp-block-embed-sgg-039-s\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"IHdPdPYdFX\"><a href=\"https:\/\/okamoto3.com\/index.php\/2021\/12\/10\/gpiozero-pinout\/1321\/\">raspberry pi \u30d4\u30f3\u78ba\u8a8d pinout \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;raspberry pi \u30d4\u30f3\u78ba\u8a8d pinout \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb&#8221; &#8212; sGG&#039;s\" src=\"https:\/\/okamoto3.com\/index.php\/2021\/12\/10\/gpiozero-pinout\/1321\/embed\/#?secret=IHdPdPYdFX\" data-secret=\"IHdPdPYdFX\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">\u52d5\u304b\u306a\u3044\u5834\u5408\u306e\u53c2\u8003<\/figcaption><\/figure><hr class=\"wp-block-separator has-css-opacity\"\/><div class=\"wp-block-image is-style-rounded\"><figure class=\"aligncenter size-thumbnail\"><a href=\"https:\/\/youtube.com\/user\/hishigeki3\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/10\/Screenshot_2021-10-25-07-00-51-667_com.google.android.youtube-01_copy_270x246.jpeg?resize=150%2C150&#038;ssl=1\" alt=\"\" class=\"wp-image-658\" srcset=\"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/10\/Screenshot_2021-10-25-07-00-51-667_com.google.android.youtube-01_copy_270x246.jpeg?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/10\/Screenshot_2021-10-25-07-00-51-667_com.google.android.youtube-01_copy_270x246.jpeg?resize=100%2C100&amp;ssl=1 100w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><figcaption class=\"wp-element-caption\">\u3088\u308d\u3057\u3051\u308c\u3070\u30c1\u30e3\u30f3\u30cd\u30eb\u767b\u9332\u3088\u308d\u3057\u304f\u304a\u9858\u3044\u7533\u3057\u4e0a\u3052\u307e\u3059\uff01<\/figcaption><\/figure><\/div><hr class=\"wp-block-separator has-css-opacity\"\/><p><center><br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/rcm-fe.amazon-adsystem.com\/e\/cm?o=9&amp;p=20&amp;l=ez&amp;f=ifr&amp;linkID=865d8e3440677383d9b2493a3354bc42&amp;t=shigeki3-22&amp;tracking_id=shigeki3-22\" width=\"120\" height=\"90\" scrolling=\"no\" border=\"0\" marginwidth=\"0\" style=\"border:none;\" frameborder=\"0\"><\/iframe><br \/>\n<\/center><\/p>","protected":false},"excerpt":{"rendered":"<p>\u30a2\u30de\u30be\u30f3\u3067\u898b\u308b \u914d\u7dda LEDbar(27, 22, 5, 6,13, 19, 26, 21, 20, 16)\u8d64led (18)\u7dd1led (23) \u524dbutton(4, hold_time=0.5)\u5f8cbutton (12,&hellip; <a class=\"more-link\" href=\"https:\/\/okamoto3.com\/index.php\/2021\/12\/13\/freenove-gpiozero-python3\/1330\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Freenove Raspberry pi \u30b9\u30bf\u30fc\u30bf\u30fc\u30ad\u30c3\u30c8 LED bar\u30c1\u30ab gpiozero Python3<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1370,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[23,213,149],"tags":[126],"class_list":["post-1330","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi","category-all-articles","category-production","tag-raspberry-pi","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/okamoto3.com\/wp-content\/uploads\/2021\/12\/led-bar_E38396E383ACE38383E38389E3839CE383BCE38389_copy_1417x714-1.jpg?fit=1417%2C714&ssl=1","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts\/1330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/comments?post=1330"}],"version-history":[{"count":15,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts\/1330\/revisions"}],"predecessor-version":[{"id":3086,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/posts\/1330\/revisions\/3086"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/media\/1370"}],"wp:attachment":[{"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/media?parent=1330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/categories?post=1330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/okamoto3.com\/index.php\/wp-json\/wp\/v2\/tags?post=1330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}