Last active
November 9, 2024 16:42
-
-
Save sandyjmacdonald/2db20b2fecccd44b39d737fdc4d14d11 to your computer and use it in GitHub Desktop.
CircuitPython USB MIDI to serial MIDI converter for Raspberry Pi Pico (RP2040)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CircuitPython USB MIDI to serial MIDI converter for Raspberry Pi Pico (RP2040). | |
# IMPORTANT! Should *only be used for MIDI in*, i.e. from USB devices to hardware | |
# MIDI synths, and *not* in the opposite direction. Doing so could risk damage to | |
# the microcontroller, your computer, or both. | |
# Wire a 10Ω resistor from the Tx pin on the Raspberry Pi Pico or other | |
# RP2040 board to the 3.5mm stereo jack tip, a 33Ω resistor from the 3v3 pin on | |
# the Raspberry Pi Pico to the 3.5mm stereo jack ring, and the ground pin on the | |
# Raspberry Pi Pico to the 3.5mm stereo jack sleeve. | |
# The code below assumes you're using USB MIDI channel 1. Change the number in | |
# square brackets on the midi_in line if you want to use a different channel. | |
import usb_midi | |
import board | |
import busio | |
midi_in = usb_midi.ports[0] | |
midi_out = busio.UART(tx=board.GP0, baudrate=31250) | |
while True: | |
msg = midi_in.read(3) | |
if len(msg): | |
midi_out.write(msg) |
Yes, I think that should work!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would you wire this to the output jack if you were using a mono cable (like in eurorack)? My instinct is tx to tip and gnd to sleeve, and leave out the 3v3 connection, but I want to confirm.