{"id":20147375,"url":"https://github.com/gdsports/circuitpython_usb_host_midi","last_synced_at":"2025-08-19T21:11:01.343Z","repository":{"id":130716014,"uuid":"169719011","full_name":"gdsports/circuitpython_usb_host_midi","owner":"gdsports","description":"CircuitPython USB Host MIDI","archived":false,"fork":false,"pushed_at":"2019-02-17T22:55:58.000Z","size":537,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T21:35:44.066Z","etag":null,"topics":["ardino","circuitpython","midi","neopixel","usb-host","ws2812"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gdsports.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-08T10:35:08.000Z","updated_at":"2024-05-21T18:18:24.000Z","dependencies_parsed_at":"2023-07-10T13:44:00.869Z","dependency_job_id":null,"html_url":"https://github.com/gdsports/circuitpython_usb_host_midi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2Fcircuitpython_usb_host_midi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2Fcircuitpython_usb_host_midi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2Fcircuitpython_usb_host_midi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsports%2Fcircuitpython_usb_host_midi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gdsports","download_url":"https://codeload.github.com/gdsports/circuitpython_usb_host_midi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248098416,"owners_count":21047436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ardino","circuitpython","midi","neopixel","usb-host","ws2812"],"created_at":"2024-11-13T22:28:47.990Z","updated_at":"2025-04-09T19:36:06.307Z","avatar_url":"https://github.com/gdsports.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Control NeoPixel using CircuityPython and USB MIDI controller\n\nOn the MIDI controller, moving fader 1 varies the red brightness, fader\n2 varies the green brightness, and fader 3 varies the blue brightness.\n\n![Metro M4 Express and USB MIDI controller](images/cpmidiled.jpg)\n\n## Hardware\n\n* Metro M4 Express and on-board NeoPixel\n* Trinket M0\n* USB OTG to host cable or adapter\n* MIDI controller (for example, Korg nanoKontroller)\n\n## Connection\n\nMIDI Controller \u003c\u003e USB OTG to host \u003c\u003e Trinket M0 \u003c\u003e Metro M4\n(nanoKontrol)      cable or adapter   Arduino\t\tCircuitPython\n\n\nM4\t|Trinket M0\n----|----------\nGND\t|GND\n5V\t|USB\nRX/0|TX/4\n\nThe M4 must receive 5V power because it powers the Trinket M0. Trinket M0 in\nturn powers the USB MIDI device.\n\n## Source code\n\n* circuitpython/cpmidineo.py\n* [https://github.com/gdsports/usbhostcopro/](https://github.com/gdsports/usbhostcopro/)\n\n### CircuitPython code\n\nThe CircuitPython program reads MIDI messages from UART Rx. Control Change\nmessages on Channel 1 control the red, green, and blue brightness of the\nNeoPixel LED on the board.\n\n```\n# Metro M4 USB Host MIDI is connected to UART Rx\n\nimport time\nimport board\nimport neopixel\nimport busio\n\nuart = busio.UART(board.TX, board.RX, baudrate=115200)\n\n# Metro M4 has one LED\npixels = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=.2)\n\nred_brightness = 0\ngreen_brightness = 0\nblue_brightness = 0\n\ndef pixels_update():\n    #print(red_brightness, green_brightness, blue_brightness)\n    pixels.fill((red_brightness, green_brightness, blue_brightness))\n    pixels.show()\n\npixels_update()\n\nwhile True:\n    data = uart.read(1)\n    #print(data)  # this is a bytearray type\n\n    if data is not None:\n        # if Change Control message on Channel 1\n        if data[0] == 0xB0:\n            control = uart.read(1)\n            if control is not None:\n                intensity = uart.read(1)\n                if intensity is not None:\n                    brightness = intensity[0] * 2\n                    # Control 0 is for red\n                    if control[0] == 0:\n                        red_brightness = brightness\n                        pixels_update()\n                    # Control 1 is for green\n                    elif control[0] == 1:\n                        green_brightness = brightness\n                        pixels_update()\n                    # Control 2 is for blue\n                    elif control[0] == 2:\n                        blue_brightness = brightness\n                        pixels_update()\n```\n\n### USB Host co-processor code\n\nThe USB Host co-processor is a Trinket M0 (or any other SAMD21 or SAMD51) board\nusing the\n[USB Host Library for SAMD](https://github.com/gdsports/USB_Host_Library_SAMD).\nThis library is a port of the\n[USB Host Shield Library 2.0](https://github.com/felis/USB_Host_Shield_2.0).\n\nThe SAMD21/SAMD51 USB port is capable of switching to USB host mode using\na [USB OTG to host cable](https://www.adafruit.com/product/1099) or adapter.\n\nThe Arduino sketch reads MIDI from the USB MIDI controller and writes the MIDI\nmessage out the UART TX pin.  The UART TX pin is connected to the Metro M4 UART\nRX pin. Both UARTs runs 115,200 bits/sec.\n\n## Related projects/references\n\n[MIDI DIN to MIDI USB Host Converter](https://github.com/gdsports/midiuartusbh)\n\n[USB Host Co-Processor](https://github.com/gdsports/usbhostcopro)\n\n[MIDI Messages](https://www.midi.org/specifications/item/table-1-summary-of-midi-message)\n\n[USB Host Library for SAMD](https://github.com/gdsports/USB_Host_Library_SAMD)\n\n[Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsports%2Fcircuitpython_usb_host_midi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgdsports%2Fcircuitpython_usb_host_midi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsports%2Fcircuitpython_usb_host_midi/lists"}