{"id":1571,"date":"2022-08-22T22:20:27","date_gmt":"2022-08-22T13:20:27","guid":{"rendered":"https:\/\/machiaworx.net\/?p=1571"},"modified":"2022-09-07T14:29:31","modified_gmt":"2022-09-07T05:29:31","slug":"macropad%e6%94%b9%e9%80%a0%ef%bc%88%e3%81%9d%e3%81%ae%ef%bc%91%ef%bc%89","status":"publish","type":"post","link":"https:\/\/machiaworx.net\/?p=1571","title":{"rendered":"MacroPad\u6539\u9020\uff08\u305d\u306e\uff11\uff09"},"content":{"rendered":"<p>\u4ee5\u524d\u30de\u30af\u30ed\u30d1\u30c3\u30c9\u3092\u8cfc\u5165\u3057\u3066\u3088\u3046\u3084\u304f\u3044\u3058\u308b\u4f59\u88d5\u304c\u3067\u304d\u305f\u306e\u3067\u3001<br \/>\n\u30d7\u30ed\u30b0\u30e9\u30e0\u66f8\u3044\u3066\u307f\u305f\u3002<\/p>\n<h3>\u7d4c\u7def<\/h3>\n<p>\u4ee5\u524d\u304b\u3089\u306e\u8171\u9798\u708e\u3067\u30e9\u30a4\u30d6\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u30c4\u30fc\u30eb\u4f5c\u3063\u305f\u308a\u3057\u3066\u3044\u305f\u304c\u3001<br \/>\n\u305d\u306e\u524d\u306b\u307e\u3068\u3082\u306b\u30ce\u30fc\u30c8\u306e\u5165\u529b\u304c\u3067\u304d\u306a\u3044\u306e\u306f\u3044\u305a\u308c\u306b\u3057\u3066\u3082\u56f0\u308b\u3002<\/p>\n<p>\u3053\u306e\u305f\u3081\u3001\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u5f62\u3092\u3057\u3066\u30ce\u30fc\u30c8\u3092\u81ea\u7531\u306b\u5165\u529b\u3067\u304d\u308b\u30c4\u30fc\u30eb\u3092\u4f5c\u308b\u4e88\u5b9a\u3002<\/p>\n<h3>\u7528\u610f<\/h3>\n<ul>\n<li>RP2040 Macropad\uff08\u672c\u6765\u306a\u3089\u81ea\u5206\u3067\u8a2d\u8a08\u3057\u3066\u3082\u3044\u3044\u3093\u3060\u3051\u3069\u3001\u307e\u305a\u306f\u304a\u8a66\u3057\uff09<\/li>\n<li>CircuitPython<\/li>\n<li>\u5404\u7a2e\u30e9\u30a4\u30d6\u30e9\u30ea<\/li>\n<\/ul>\n<h3>\u30b3\u30fc\u30c9<\/h3>\n<p>\u5272\u3068\u9069\u5f53\u306b\u66f8\u3044\u3066\u3082\u52d5\u304f\u306e\u3067\u4fbf\u5229\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n\r\nimport board\r\nimport time\r\nimport random\r\nimport usb_midi\r\nimport adafruit_midi\r\nimport simpleio\r\n\r\nfrom adafruit_midi.control_change import ControlChange\r\nfrom adafruit_midi.note_off import NoteOff\r\nfrom adafruit_midi.note_on import NoteOn\r\nfrom adafruit_midi.pitch_bend import PitchBend\r\nfrom digitalio import DigitalInOut, Pull\r\nfrom adafruit_macropad import MacroPad\r\nfrom adafruit_display_text import label\r\n\r\nbutton = [DigitalInOut(board.KEY1),\r\n    DigitalInOut(board.KEY2),\r\n    DigitalInOut(board.KEY3),\r\n    DigitalInOut(board.KEY4),\r\n    DigitalInOut(board.KEY5),\r\n    DigitalInOut(board.KEY6),\r\n    DigitalInOut(board.KEY7),\r\n    DigitalInOut(board.KEY8),\r\n    DigitalInOut(board.KEY9),\r\n    DigitalInOut(board.KEY10),\r\n    DigitalInOut(board.KEY11),\r\n    DigitalInOut(board.KEY12),\r\n]\r\n\r\n# \u30ce\u30fc\u30c8\u7ba1\u7406\r\nnote=[0,0,0,0,0,0, 0,0,0,0,0,0]\r\nnote_vel=[0,0,0,0,0,0, 0,0,0,0,0,0]\r\nnote_state=[False,False,False,False,False,False,\r\nFalse,False,False,False,False,False]\r\n\r\nfor i in range(12):\r\n    button[i].pull = Pull.UP # \u5185\u90e8\u306e\u30d7\u30eb\u30a2\u30c3\u30d7\u62b5\u6297\u3092\u6709\u52b9\u5316\u3059\u308b\r\n    note[i]=0\r\n    note_vel[i]=0\r\n    print(button[i].value)\r\n\r\nled = simpleio.DigitalOut(board.LED)\r\n\r\n# MIDI\u30dd\u30fc\u30c8\u306e\u5165\u51fa\u529b\u306b\u3064\u3044\u3066\u30c7\u30d0\u30a4\u30b9\u53d6\u5f97\r\nmidi = adafruit_midi.MIDI(\r\n    midi_out=usb_midi.ports[1], out_channel=0\r\n)\r\n\r\nwhile True:\r\n    nt=0\r\n    for i in range(12):\r\n        if button[i].value==False:\r\n            if note_state[i]==False:\r\n                nt=i+45\r\n                midi.send(NoteOn( nt, 120)) \r\n                note_state[i]=True \r\n        else:\r\n            if note_state[i]==True:\r\n                nt=i+45\r\n                midi.send(NoteOff(nt, 120))\r\n                note_state[i]=False\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u30de\u30af\u30ed\u30d1\u30c3\u30c9\u3092\u8cfc\u5165\u3057\u3066\u3088\u3046\u3084\u304f\u3044\u3058\u308b\u4f59\u88d5\u304c\u3067\u304d\u305f\u306e\u3067\u3001 \u30d7\u30ed\u30b0\u30e9\u30e0\u66f8\u3044\u3066\u307f\u305f\u3002 \u7d4c\u7def \u4ee5\u524d\u304b\u3089\u306e\u8171\u9798\u708e\u3067\u30e9\u30a4\u30d6\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u30c4\u30fc\u30eb\u4f5c\u3063\u305f\u308a\u3057\u3066\u3044\u305f\u304c\u3001 \u305d\u306e\u524d\u306b\u307e\u3068\u3082\u306b\u30ce\u30fc\u30c8\u306e\u5165\u529b\u304c\u3067\u304d\u306a\u3044\u306e\u306f\u3044\u305a\u308c\u306b\u3057\u3066\u3082\u56f0\u308b\u3002 \u3053&hellip; <span class=\"clear\"><\/span><a href=\"https:\/\/machiaworx.net\/?p=1571\" class=\"more-link read-more\" rel=\"bookmark\"><span class=\"screen-reader-text\">MacroPad\u6539\u9020\uff08\u305d\u306e\uff11\uff09<\/span><i class=\"fa fa-arrow-right\"><\/i> \u306e\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,23,4],"tags":[],"class_list":["post-1571","post","type-post","status-publish","format-standard","hentry","category-synth-dev","category-embed","category-pgm"],"_links":{"self":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts\/1571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1571"}],"version-history":[{"count":3,"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts\/1571\/revisions"}],"predecessor-version":[{"id":1574,"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts\/1571\/revisions\/1574"}],"wp:attachment":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}