Using USB Host in a Teensy 4.0 to add 5 Pin MIDI to a cheap USB keyboard


Well-known member
I am posting this here in hopes that it might help someone with similar interests. I purchased a MIDI USB Host box a few years ago from MidiPlus. That thing never worked, so I often thought about putting a Teensy 4.1 in the box to make a stable piece of equipment.

I learned how to use the Teensy 4.1 USB Host. I got it working with a cheap USB-only MIDI keyboard.
I was able to route the USB MIDI out to a 5-Pin MIDI line via pin 3 (Serial1 TX) on the Teensy.

In this particular case, what I really wanted was a way to take a cheapo M-Audio USB Keyrig 49 keyboard and make it work with my 5-Pin MIDI gear.
I added a buck converter and a barrel jack for an adapter. I had a spare Teensy 4.0, so I used the same code I used with the Teensy 4.1 with the Teensy 4.0.
Because I had a fixed power supply for the M-Audio main board and the Teensy, all I had to do was wire up power, USB D+ and D-1, and add a MIDI port.

(Montage of spray-painting the keyboard and hot-gluing scrap metal into base to make it weigh something.)

I used code which was copied almost verbatim from, and then added code to the handlers to route the USB input to a serial MIDI output.

The main point I am trying make here, is although USB Host mode is complex and the power issues can be risky and unstable, if you are powering everything with the same internal power supply, USB Host mode with a Teensy 4.0 is a straightforward way to make cheap laptop-friendly USB MIDI devices become more useful. I have a Casio WK-220 with a nice weighted keyboard and lots of sounds, and 5 Pin MIDI would let me tie it into my drum machines and groove boxes.

Of course, I also now have a nice 4 octave keyboard with a Teensy 4.0 inside. If I add a DAC and some audio output jacks, I can have more fun.
This has been a very inexpensive project with gratifying results.