{"id":5130,"date":"2021-08-14T15:07:56","date_gmt":"2021-08-14T06:07:56","guid":{"rendered":"https:\/\/ndaznnez.com\/blog7\/?p=5130"},"modified":"2025-02-04T18:09:10","modified_gmt":"2025-02-04T09:09:10","slug":"raspberry-pi-pico%e3%81%a8%e3%82%84%e3%82%8b%e6%b0%97%e3%81%ae%e3%81%aa%e3%81%84%e4%bf%a1%e5%8f%b7%e6%a9%9f%e5%86%8d%e6%9d%a5","status":"publish","type":"post","link":"https:\/\/ndaznnez.com\/blog7\/2021\/08\/14\/raspberry-pi-pico%e3%81%a8%e3%82%84%e3%82%8b%e6%b0%97%e3%81%ae%e3%81%aa%e3%81%84%e4%bf%a1%e5%8f%b7%e6%a9%9f%e5%86%8d%e6%9d%a5\/","title":{"rendered":"Raspberry Pi Pico\u3068\u3084\u308b\u6c17\u306e\u306a\u3044\u4fe1\u53f7\u6a5f\u518d\u6765"},"content":{"rendered":"\n<p>Raspberry Pi Pico\u306b\u3088\u308b\u3057\u3087\u3046\u3082\u306a\u3044\u30b7\u30b9\u30c6\u30e0\u306e\u5c02\u7528\u6a5f\u5316\u3001\u305d\u306e\u7b2c\u4e00\u5f3e\u300c<a href=\"https:\/\/ndaznnez.com\/blog7\/2020\/05\/24\/%e3%82%84%e3%82%8b%e6%b0%97%e3%81%ae%e3%81%aa%e3%81%84%e4%bf%a1%e5%8f%b7%e6%a9%9f-raspi%e9%81%8a%e3%81%b3\/\">\u3084\u308b\u6c17\u306e\u306a\u3044\u4fe1\u53f7\u6a5f<\/a>\u300d\u3002<\/p>\n\n\n\n<p>\u6614\u4f5c\u3063\u305fPython\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u3001\u5148\u65e5\u306e\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30d1\u30bd\u30b3\u30f3\u306e\u30b7\u30b9\u30c6\u30e0\u306e\u30af\u30e9\u30c3\u30b7\u30e5\u3068\u5171\u306b\u5931\u308f\u308c\u3001\u307e\u305fRaspberry Pi model 4B\u306e\u4e2d\u306b\u3082\u3042\u3063\u305f\u306f\u305a\u3060\u304c\u3001\u30bf\u30c3\u30c1\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u3092\u8a66\u3057\u3066\u3046\u307e\u304f\u884c\u304b\u306a\u304b\u3063\u305f\u3068\u304d\u306b\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u30af\u30ea\u30fc\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u4f55\u56de\u3082\u3057\u3066\u3044\u3066\u8de1\u5f62\u3082\u306a\u3044\u306e\u3067\u3001\u4ed5\u65b9\u306a\u304f\u4f5c\u308a\u76f4\u3057\u305f\u3002\u4ed6\u4eba\u306e\u53c2\u8003\u306b\u306f\u307e\u3063\u305f\u304f\u306a\u3089\u306a\u3044\u304c\u3001\u4eca\u5f8c\u3053\u3046\u3044\u3063\u305f\u3053\u3068\u306e\u306a\u3044\u3088\u3046\u3001\u81ea\u5206\u306e\u5b89\u5168\u306e\u305f\u3081\u306b\u672b\u5c3e\u306b\u7f6e\u3044\u3066\u304a\u304f\u3002\u4f55\u3068\u306a\u304f\u524d\u56de\u3068GPIO\u3060\u304bPWM(Pulse Width Modulation)\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u304a\u4f5c\u6cd5\u304c\u9055\u3063\u3066\u3044\u308b\u3088\u3046\u306a\u6c17\u304c\u3059\u308b\u304c\u3001\u52d5\u3051\u3070\u826f\u3044\u3002\u4eca\u56de\u306f\u3001\u5c02\u7528\u6a5f\u5316\u306b\u5411\u3051\u3066\u3001\u30d6\u30ec\u30c3\u30c9\u30dc\u30fc\u30c9\u4e0a\u3067\u306e\u30b7\u30b9\u30c6\u30e0\u306e\u5fa9\u65e7\u307e\u3067\u3002\u57fa\u677f\u304c\u5c4a\u3044\u305f\u5f8c\u672c\u683c\u7684\u306b\u4f5c\u696d\u3057\u305f\u3044<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"480\" style=\"aspect-ratio: 640 \/ 480;\" width=\"640\" controls src=\"https:\/\/ndaznnez.com\/blog7\/wp-content\/uploads\/2021\/08\/Video.mp4\"><\/video><\/figure>\n\n\n\n<p>\u3053\u3046\u3057\u3066\u4f5c\u3063\u3066\u898b\u305f\u304c\u3001\u5404\u8272\u306e\u8f1d\u5ea6\u3092\u5408\u308f\u305b\u308b\u305f\u3081LED\u6bce\u306b\u96fb\u6d41\u5236\u9650\u62b5\u6297\u306e\u6570\u3068\u3064\u306a\u304e\u65b9\u306b\u898b\u4e8b\u306a\u30d0\u30e9\u30a8\u30c6\u30a3\u304c\u3067\u304d\u305f\u3002\u79c1\u306f\u4eca330\u03a9\u306e\u62b5\u6297\u3057\u304b\u6301\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u7dd1\u306f2\u672c\u4e26\u5217(165\u03a9)\u3001\u9ec4\u8272\u306f2\u672c\u76f4\u5217(660\u03a9)\u3001\u8d64\u306f3\u672c\u76f4\u5217(1k\u03a9)\u3068\u3044\u3046\u7d44\u307f\u5408\u308f\u305b\u306b\u306a\u3063\u305f\u3002\u4e0a\u306e\u7d75\u3092\u898b\u3066\u3082\u3089\u3048\u3070\u4f55\u3068\u306a\u304f\u308f\u304b\u308b\u3060\u308d\u3046\u304b\u3002\u8aa0\u306b\u8da3\u6df1\u3044\u3082\u306e\u304c\u3042\u308b\u3002\u9ec4\u8272\u3044LED\u306e\u30b5\u30a4\u30ba\u304c\u4ed6\u3068\u7570\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u3068\u4f75\u305b\u3001\u3053\u3046\u306a\u308b\u3068\u8a6b\u3073\u5bc2\u3073\u306e\u4e16\u754c\u3068\u8a00\u3063\u3066\u3082\u904e\u8a00\u3067\u306f\u306a\u3044\u3060\u308d\u3046(\u904e\u8a00\u3060\u308d\u3046)<\/p>\n\n\n\n<p>\u3053\u306e\u52d5\u753b\u306e\u5834\u5408\u3001\u9752(\u7dd1)\u306f\u3044\u3084\u3044\u3084\u306a\u304c\u3089\u5f90\u3005\u306b\u70b9\u706f\u3059\u308b\u304c\u3001\u305d\u308c\u306a\u308a\u306b\u6301\u7d9a\u3057\u3066(\u77ed\u3044\u304c)\u3059\u3063\u3068\u6d88\u3048\u308b\u3002\u7d9a\u304f\u9ec4\u8272\u306f\u5c0f\u7c92\u3060\u304c\u3074\u308a\u308a\u3068\u70b9\u706f\u3057\u3066\u3001\u9752\u3088\u308a\u9811\u5f35\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u30a2\u30d4\u30fc\u30eb\u3059\u308b\u3002\u6700\u4f4e\u306a\u306e\u304c\u8d64\u3067\u3001\u9ec4\u8272\u304c\u6d88\u706f\u3059\u308b\u3084\u5426\u3084\u5acc\u306a\u3053\u3068\u306f\u3055\u3063\u3055\u3068\u7247\u3065\u3051\u3066\u3001\u3068\u4e00\u5fdc\u7acb\u3061\u4e0a\u304c\u308a\u306f\u3059\u308b\u304c\u3001\u6700\u4f4e\u9650\u4fdd\u6301\u3057\u305f\u3089\u5f8c\u306f\u3074\u3057\u3083\u308a\u3068\u6d88\u706f\u3057\u3066\u3067\u304d\u308b\u3060\u3051\u30a8\u30cd\u30eb\u30ae\u30fc\u3092\u6e29\u5b58\u3057\u3088\u3046\u3068\u3059\u308b\u3002\u305d\u306e\u5f8c\u3001\u9752\u306f\u3082\u3046\u81ea\u5206\u306e\u756a\u304c\u6765\u305f\u306e\u304b\u3068\u3070\u304b\u308a\u306b\u9762\u5012\u81ed\u305d\u3046\u306b\u5c11\u3057\u9593\u3092\u304a\u3044\u3066\u3088\u3063\u3053\u3044\u3057\u3087\u3001\u3068\u8170\u3092\u4e0a\u3052\u308b\u2026\u3068\u3044\u3046\u30a4\u30e1\u30fc\u30b8<\/p>\n\n\n\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e2d\u3001duty\u30b5\u30a4\u30af\u30eb\u306e\u7bc4\u56f2\u3068\u5897\u6e1b\u306e\u523b\u307f\u5024(i\u306e\u5024 &#8211; \u660e\u308b\u304f\u306a\u3063\u305f\u308a\u6697\u304f\u306a\u3063\u305f\u308a\u306e\u5e45\u3068\u5897\u6e1b\u306e\u523b\u307f\u5e45)\u3001sleep\u306e\u6642\u9593\u8a2d\u5b9a( \u660e\u308b\u304f\u306a\u3063\u305f\u308a\u6697\u304f\u306a\u3063\u305f\u308a\u306e\u5897\u6e1b\u306e\u523b\u307f\u306e\u4fdd\u6301\u6642\u9593\u3084\u3001\u9752 &#8211; \u9ec4 &#8211; \u8d64\u306e\u79fb\u308a\u5909\u308f\u308a\u306e\u9593\u306e\u53d6\u308a\u65b9)\u3067\u3001\u3044\u308d\u3044\u308d\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u5b9f\u73fe\u3067\u304d\u308b\u3002\u3053\u3053\u3067\u306f\u8d64\u8272\u306eLED\u306e\u51e6\u7406\u306e\u90e8\u5206\u306f\u5f90\u3005\u306b\u6e1b\u5149\u3059\u308b\u90e8\u5206\u3092\u3042\u3048\u3066\u7121\u52b9\u306b\u3057\u3066\u3042\u308b\u304c\u3001\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u3042\u308b\u3060\u3051\u306a\u306e\u3067\u5fc5\u8981\u3067\u3042\u308c\u3070\u5fa9\u6d3b\u3055\u305b\u3089\u308c\u308b<\/p>\n\n\n\n<p>\u4eba\u305d\u308c\u305e\u308c\u306e\u3084\u308b\u6c17\u306e\u306a\u3055\u306e\u8868\u73fe\u306b\u4f7f\u3048\u308b\u304b\u3082\u77e5\u308c\u306a\u3044\u3002<strong>\u3084\u308b\u6c17\u306e\u306a\u3055\u30b3\u30f3\u30c6\u30b9\u30c8<\/strong>\u3067\u3082\u3084\u308b\u304b<\/p>\n\n\n\n<p>\u5c02\u7528\u6a5f\u5316\u306b\u3042\u305f\u3063\u3066\u3001\u57fa\u677f\u3092\u6ce8\u6587\u3057\u3066\u5c4a\u304f\u307e\u3067\u306e\u9593\u306b\u672c\u4eba\u306e\u3084\u308b\u6c17\u304c\u5931\u305b\u306a\u3044\u304b\u304c\u554f\u984c\u3060<\/p>\n\n\n\n<p class=\"has-text-align-right\">2021\/08\/14<br>\u3093\u306d\u305e\u3046<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-white-color has-text-color has-background has-normal-font-size\" style=\"background-color:#002244\">from machine import PWM, Pin\nimport time\n\n# Pin 7:Green 9:Yellow 10:Red (in GPIO nomenclature)\n\nGreen = PWM(Pin(7))\nYellow = PWM(Pin(9))\nRed = PWM(Pin(10))\n\nmax_duty = 65025\n\nwhile True:\n    i=0\n    while i&lt;25:\n        Green.duty_u16(int(max_duty*i\/100))\n        time.sleep(0.03)\n        i+=0.4\n    time.sleep(0.1)\n    while i&gt;=0:\n        Green.duty_u16(int(max_duty*i\/100))\n        time.sleep(0.005)\n        i-=0.5\n#    Green.duty_u16(int(0))\n    time.sleep(0.8)\n\n    i=0\n    while i&lt;100:\n        Yellow.duty_u16(int(max_duty*i\/100))\n        time.sleep(0.03)\n        i+=2\n    time.sleep(1)\n    while i&gt;=0:\n        Yellow.duty_u16(int(max_duty*i\/100))\n        time.sleep(0.001)\n        i-=1\n#    Yellow.duty_u16(int(0))\n#    time.sleep(0.3)\n\n    i=0\n    while i&lt;=100:\n        Red.duty_u16(int(max_duty*i\/100))\n        time.sleep(0.005)\n        i+=2\n    time.sleep(0.05)\n    Red.duty_u16(0)\n#    while i&gt;=0:\n#        Red.duty_u16(int(max_duty*i\/100))\n#        time.sleep(0.001)\n#        i-=2\n#    Red.duty_u16(int(0))\n    time.sleep(1)\n\nGPIO.cleanup(Red)\nGPIO.cleanup(Yellow)\nGPIO.cleanup(Green)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Raspberry Pi Pico\u306b\u3088\u308b\u3057\u3087\u3046\u3082\u306a\u3044\u30b7\u30b9\u30c6\u30e0\u306e\u5c02\u7528\u6a5f\u5316\u3001\u305d\u306e\u7b2c\u4e00\u5f3e\u300c\u3084\u308b\u6c17\u306e\u306a\u3044\u4fe1\u53f7\u6a5f\u300d\u3002 \u6614\u4f5c\u3063\u305fPython\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u3001\u5148\u65e5\u306e\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30d1\u30bd\u30b3\u30f3\u306e\u30b7\u30b9\u30c6\u30e0\u306e\u30af\u30e9\u30c3\u30b7\u30e5\u3068\u5171\u306b\u5931\u308f\u308c\u3001\u307e\u305fRasp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5154,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5,7],"tags":[79,92,38,39],"class_list":["post-5130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","category-5","category-7","tag-79","tag-92","tag-38","tag-39"],"_links":{"self":[{"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/posts\/5130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/comments?post=5130"}],"version-history":[{"count":17,"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/posts\/5130\/revisions"}],"predecessor-version":[{"id":5185,"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/posts\/5130\/revisions\/5185"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/media\/5154"}],"wp:attachment":[{"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/media?parent=5130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/categories?post=5130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ndaznnez.com\/blog7\/wp-json\/wp\/v2\/tags?post=5130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}