{"id":191,"date":"2024-08-08T14:13:28","date_gmt":"2024-08-08T05:13:28","guid":{"rendered":"http:\/\/uto.lab-somehow.net\/?p=191"},"modified":"2025-08-13T14:11:12","modified_gmt":"2025-08-13T05:11:12","slug":"raspberry-pi-pico%e3%81%a7%e3%82%b9%e3%82%a4%e3%83%bc%e3%83%97%e3%82%92%e9%b3%b4%e3%82%89%e3%81%99","status":"publish","type":"post","link":"http:\/\/uto.lab-somehow.net\/?p=191","title":{"rendered":"Raspberry Pi Pico\u3067\u30b9\u30a4\u30fc\u30d7\u3092\u9cf4\u3089\u3059"},"content":{"rendered":"\n<p>\u4eca\u56de\u306fRaspberry Pi Pico\u3068\u30d1\u30c3\u30b7\u30d6\u30d6\u30b6\u30fc\u3067\u30b9\u30a4\u30fc\u30d7\u3092\u9cf4\u3089\u3057\u307e\u3059<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u30d1\u30c3\u30b7\u30d6\u30d6\u30b6\u30fc\u3068\u306f<\/strong><\/h2>\n\n\n\n<p>\u30d1\u30c3\u30b7\u30d6\u30d6\u30b6\u30fc\u306f\u3001\u96fb\u6c17\u4fe1\u53f7\u304c\u304b\u304b\u308b\u3068\u97f3\u3092\u767a\u751f\u3059\u308b\u88c5\u7f6e\u3067\u3059\u3002\u97f3\u3092\u767a\u751f\u3055\u305b\u308b\u305f\u3081\u306b\u306f\u3001\u30de\u30a4\u30af\u30ed\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306a\u3069\u304b\u3089\u306e\u5916\u90e8\u4fe1\u53f7\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"827\" src=\"http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/Image-18-1024x827.jpg\" alt=\"\" class=\"wp-image-196\" srcset=\"http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/Image-18-1024x827.jpg 1024w, http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/Image-18-300x242.jpg 300w, http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/Image-18-768x621.jpg 768w, http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/Image-18-1536x1241.jpg 1536w, http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/Image-18-700x566.jpg 700w, http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/Image-18.jpg 1589w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u30b9\u30a4\u30fc\u30d7\u3068\u306f<\/strong><\/h2>\n\n\n\n<p>20Hz\u306e\u4f4e\u97f3\u304b\u308920kH\u307e\u3067\u5f90\u3005\u306b\u30b5\u30a4\u30f3\u6ce2\u304c\u5909\u5316\u3059\u308b\u4fe1\u53f7\u306e\u3053\u3068\u3067\u3059\u3002\u97f3\u3067\u3044\u3048\u3070\u3001\u4f4e\u3044\u97f3\u304b\u3089\u9ad8\u3044\u97f3\u3078\u6ed1\u3089\u304b\u306b\u5909\u308f\u3063\u3066\u3044\u304f\u97f3\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u9ad8\u9f62\u8005\u3067\u3082\u805e\u304d\u53d6\u308a\u3084\u3059\u3044\u305f\u3081\u3001\u30b5\u30a4\u30ec\u30f3\u306e\u97f3\u306a\u3069\u306b\u3082\u30b9\u30a4\u30fc\u30d7\u97f3\u306f\u6d3b\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import machine\nimport time\n\n\ndef play_tone(frequency, duration):\n    \"\"\"\u97f3\u518d\u751f\n\n    \u6307\u5b9a\u3055\u308c\u305f\u5468\u6ce2\u6570\u306e\u97f3\u3092\u6307\u5b9a\u3055\u308c\u305f\u6642\u9593\u3060\u3051\u518d\u751f\u3059\u308b\n\n    Args:\n        frequency: \u5468\u6ce2\u6570 (Hz)\n        duration: \u97f3\u306e\u6301\u7d9a\u6642\u9593 (\u30df\u30ea\u79d2)\n    Return:\n        None\n    Example:\n        play_tone(440, 1000)  # 440Hz\u306e\u97f3\u30921\u79d2\u9593\u518d\u751f\n    \"\"\"\n    buzzer.freq(frequency)\n    buzzer.duty_u16(32768)  # \u30c7\u30e5\u30fc\u30c6\u30a3\u30b5\u30a4\u30af\u30eb\u309250%\u306b\u8a2d\u5b9a\n    time.sleep_ms(duration)\n    buzzer.duty_u16(0)  # \u97f3\u3092\u505c\u6b62\n\n\ndef sweep_tone(start_freq, end_freq, step, duration):\n    \"\"\"\u30b9\u30a4\u30fc\u30d7\u97f3\u751f\u6210\n\n    \u6307\u5b9a\u3055\u308c\u305f\u5468\u6ce2\u6570\u7bc4\u56f2\u306e\u30b9\u30a4\u30fc\u30d7\u97f3\u3092\u751f\u6210\u3059\u308b\n\n    Args:\n        start_freq: \u958b\u59cb\u5468\u6ce2\u6570 (Hz)\n        end_freq: \u7d42\u4e86\u5468\u6ce2\u6570 (Hz)\n        step: \u5468\u6ce2\u6570\u306e\u5897\u6e1b\u30b9\u30c6\u30c3\u30d7\n        duration: \u5404\u30c8\u30fc\u30f3\u306e\u6301\u7d9a\u6642\u9593 (\u30df\u30ea\u79d2)\n    Return:\n        None\n    Example:\n        sweep_tone(1000, 100, 1, 10)  # 1000Hz\u304b\u3089100Hz\u307e\u30671Hz\u305a\u3064\u4e0b\u304c\u308a\u306a\u304c\u308910ms\u305a\u3064\u518d\u751f\n    \"\"\"\n    # \u5468\u6ce2\u6570\u304c\u5897\u52a0\u3059\u308b\u5834\u5408\n    if start_freq &lt; end_freq:\n        for freq in range(start_freq, end_freq, step):\n            play_tone(freq, duration)\n    # \u5468\u6ce2\u6570\u304c\u6e1b\u5c11\u3059\u308b\u5834\u5408\n    else:\n        for freq in range(start_freq, end_freq, -step):\n            play_tone(freq, duration)\n\n\n# PWM\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306bGPIO15\u3092\u8a2d\u5b9a\nbuzzer = machine.PWM(machine.Pin(15))\n\n# \u30b9\u30a4\u30fc\u30d7\u97f3\u306e\u8a2d\u5b9a\nstart_frequency = 20  # \u958b\u59cb\u5468\u6ce2\u6570\nend_frequency = 2000  # \u7d42\u4e86\u5468\u6ce2\u6570\nstep_frequency = 1  # \u5468\u6ce2\u6570\u306e\u5897\u6e1b\u30b9\u30c6\u30c3\u30d7\ntone_duration = 1  # \u5404\u30c8\u30fc\u30f3\u306e\u6301\u7d9a\u6642\u9593 (\u30df\u30ea\u79d2)\n\ntry:\n    sweep_tone(start_frequency, end_frequency, step_frequency, tone_duration)\nfinally:\n    # \u30d6\u30b6\u30fc\u3092\u505c\u6b62\n    buzzer.duty_u16(0)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u30dd\u30a4\u30f3\u30c8\u2460 \u30c7\u30e5\u30fc\u30c6\u30a3\u30b5\u30a4\u30af\u30eb\u3068\u306f<\/strong><\/h3>\n\n\n\n<p>\u30c7\u30e5\u30fc\u30c6\u30a3\u30b5\u30a4\u30af\u30eb\uff08\u30c7\u30e5\u30fc\u30c6\u30a3\u6bd4\uff09\u3068\u306f\u3001\u4e00\u5b9a\u5468\u671f\u3067\u9023\u7d9a\u3059\u308b\u30d1\u30eb\u30b9\u6ce2\u306b\u304a\u3044\u3066\u3001\u30d1\u30eb\u30b9\u304c\u30aa\u30f3\u306b\u306a\u308b\u6642\u9593\u3068\u30aa\u30d5\u306b\u306a\u308b\u6642\u9593\u306e\u6bd4\u7387\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u30dd\u30a4\u30f3\u30c8\u2461 PWM\u3068\u306f<\/strong><\/h3>\n\n\n\n<p>PWM(Pulse Width Modulation)\u3068\u306f\u3001\u30d1\u30eb\u30b9\u5e45\u5909\u8abf\u306e\u7565\u3067\u3001\u534a\u5c0e\u4f53\u3092\u4f7f\u3063\u305f\u96fb\u529b\u5236\u5fa1\u65b9\u5f0f\u306e\u4e00\u3064\u3067\u3059\u3002\u30aa\u30f3\u3068\u30aa\u30d5\u306e\u7e70\u308a\u8fd4\u3057\u306b\u3088\u3063\u3066\u3001\u51fa\u529b\u3055\u308c\u308b\u96fb\u529b\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u52d5\u4f5c<\/h2>\n\n\n\n<p>\u5b9f\u969b\u306b\u97f3\u3092\u9cf4\u3089\u3057\u305f\u69d8\u5b50\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"960\" style=\"aspect-ratio: 540 \/ 960;\" width=\"540\" controls src=\"http:\/\/uto.lab-somehow.net\/wp-content\/uploads\/2024\/08\/MicrosoftTeams-video-1.mp4\"><\/video><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081\u30fb\u611f\u60f3<\/h2>\n\n\n\n<p>\u975e\u5e38\u306b\u5358\u7d14\u306a\u914d\u7dda\u3067\u30b9\u30a4\u30fc\u30d7\u97f3\u3092\u9cf4\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u5358\u7d14\u306a\u30eb\u30fc\u30d7\u51e6\u7406\u3067\u3059\u304c\u3001\u6ed1\u3089\u304b\u306b\u97f3\u304c\u5909\u5316\u3057\u3066\u3044\u308b\u3088\u3046\u306b\u805e\u3053\u3048\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u30b9\u30a4\u30fc\u30d7\u97f3\u306f\u9ad8\u9f62\u8005\u3082\u805e\u304d\u53d6\u308a\u3084\u3059\u3044\u305f\u3081\u30b5\u30a4\u30ec\u30f3\u7b49\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u3068\u77e5\u308a\u3001\u78ba\u304b\u306b\u8b66\u544a\u306a\u3069\u306e\u30b5\u30a4\u30ec\u30f3\u306f\u4e00\u5b9a\u306e\u97f3\u3067\u306f\u306a\u3044\u3068\u6c17\u3065\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/soundqualitylab.com\/test_tones\/01_sinewave\/11_sweep\/\">sound quality lab\u300c\u30b9\u30a4\u30fc\u30d7\u4fe1\u53f7\u300d<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.sunfounder.com\/projects\/ultimate-sensor-kit\/ja\/latest\/components_basic\/26-component_buzzer.html\">SunFounder \u300c\u30d1\u30c3\u30b7\u30d6\u30d6\u30b6\u30fc\u300d<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/analog-pcb.com\/glossary\/%E3%83%87%E3%83%A5%E3%83%BC%E3%83%86%E3%82%A3%E3%83%BC%E6%AF%94-%E3%83%87%E3%83%A5%E3%83%BC%E3%83%86%E3%82%A3%E3%83%BC%E3%82%B5%E3%82%A4%E3%82%AF%E3%83%AB\/\">\u30a2\u30ca\u30ed\u30b0\u56de\u8def\u30fb\u57fa\u677f \u8a2d\u8a08\u88fd\u4f5c.com \u300c\u30c7\u30e5\u30fc\u30c6\u30a3\u30fc\u6bd4 (\u30c7\u30e5\u30fc\u30c6\u30a3\u30fc\u30b5\u30a4\u30af\u30eb)\u300d<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/toshiba.semicon-storage.com\/jp\/semiconductor\/knowledge\/e-learning\/brushless-motor\/chapter3\/what-pwm.html\">\u6771\u829d\u30c7\u30d0\u30a4\u30b9\uff06\u30b9\u30c8\u30ec\u30fc\u30b8\u682a\u5f0f\u4f1a\u793e \u300cPWM\u3068\u306f\u300d<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fRaspberry Pi Pico\u3068\u30d1\u30c3\u30b7\u30d6\u30d6\u30b6\u30fc\u3067\u30b9\u30a4\u30fc\u30d7\u3092\u9cf4\u3089\u3057\u307e\u3059 \u30d1\u30c3\u30b7\u30d6\u30d6\u30b6\u30fc\u3068\u306f \u30d1\u30c3\u30b7\u30d6\u30d6\u30b6\u30fc\u306f\u3001\u96fb\u6c17\u4fe1\u53f7\u304c\u304b\u304b\u308b\u3068\u97f3\u3092\u767a\u751f\u3059\u308b\u88c5\u7f6e\u3067\u3059\u3002\u97f3\u3092\u767a\u751f\u3055\u305b\u308b\u305f\u3081\u306b\u306f\u3001\u30de\u30a4\u30af\u30ed\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306a\u3069\u304b\u3089\u306e\u5916\u90e8\u4fe1\u53f7&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":5,"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":200,"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions\/200"}],"wp:attachment":[{"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/uto.lab-somehow.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}