Building a USB MIDI controller

Figure 1: A basic 6-button footswitch USB MIDI controller. LEDs show button state.
I’m working on some pieces at the moment that require some electronics to be triggered via footpedals in performance. The problem is that I don’t have any MIDI foot pedals, and those that exist are expensive or overkill or both. All I need is a simple, passive MIDI pedal, connectable via USB that can give me a bunch of footswitch triggers (and maybe more features down the road). So, I decided that I’d build my own, and thought that if I documented the (surprisingly easy) process, others might see how easy it is to get custom hardware controllers…

There are a few simple options out there. In the first instance, an Arduino would probably cut it. I could use the serial port, or run a MIDI library to get what I need. Arduino is simple to learn, but I didn’t really need all the extras (or the board size). A Teensy is a smaller, equally affordable, and in some cases, a more versatile microcontroller that gets used a lot in USB MIDI and Music Tech related projects. And there’s a handy MIDI library already out there. So I opted for a Teensy (v3.2).

I sourced a cheap aluminium box here (a nice diecast Hammond box would have been lovely and heavier duty, but they’re expensive. This (Takachi Electric Industrial, MB-14) was 5 quid). For my current purposes, I only need 4 switches, but I got carried away and cut holes for 6 — not realising that this narrows the footprint considerably, making this a tricky thing to trigger with shoes on. It’s also a real mess of wiring inside as a result. If I’d thought about it before, I would have limited the switches to 4. As they say: measure twice, cut once. Lesson learned.

Switches are simple momentary (not-latching) switches, with some LEDs for visual confirmation. Below is a quick breadboard mock-up of the setup:
Figure 2: A breadboard mock-up of the circuit (in the finished product, I skipped the breadboard and chained the ground on each component) [made with Fritzing]
Figure 3: I took the strain off of the Teensy’s USB port by adding a panel-mount USB cable. It also allows me to use a slightly heavier-duty USB-B-type connector, as opposed to the Teensy’s micro port.
The code for the Teensy is simple given Josh Nishikawa’s MIDI controller library available here (Note, that I’m interested in MIDI controller numbers/values, not MIDI notes, Teensy can handle regular notes without a library). I’m only using the Pushbutton, assigned as MIDI control numbers (20-25) as they’re typically unassigned. This could also be serial, or MIDI note numbers rather than controller number. The code is simple: when a footswitch is pushed, fire off a MIDI control value of 127, otherwise it’s zero. When the pedal goes down, the LED pin is also lit up. In Max, all I need to read this is a [ctlin], [pak] and a [route 20 21 22 23 24 25] and I’ve got my pedal triggers into Max (see .maxpat in my git below). Easy.

In the Arduino IDE (Teensy uses the Arduino IDE, just with an additional library. There’s a guide to getting started with it here), I wanted the MIDI device to show up with it’s own name, so use the {name.c} file to set that. Set your USB Type to ‘MIDI’ in the Tools menu, and set your Board to ‘Teensy 3.2’, upload all that to the board and you’re done! A cheap, custom MIDI controller…

Improvements:

  • We’re gonna need a bigger boat. The initial plan was to include jack sockets and a stereo TRS jack so that I could plug in keyboard sustain pedals and an expression pedal to read as MIDI controllers. The code is simple, but since I didn’t leave myself enough space in the box, they won’t fit now.
  • Push-and-hold. My Max patch takes care of held buttons for flexibility, but this could easily be programmed in at the MIDI device level. Currently, if a button is held for x seconds or more, it clears a buffer.
    • Writing in at the Teensy level would let me have LED feedback too (light flashes after x seconds). I suppose I could set this anyway, but without it linking directly to the Max value (via serial?) there’s little point.

Files:

8 thoughts on “Building a USB MIDI controller”

  1. Hi, could you build a 2 button version to order?
    I bought a QSC mixing desk that uses midi via usb to control effects, the only pedal I can find on the market is in the US so would be hammered by import duty.

    1. Hi! Unfortunately I can’t make these to order, I don’t have much time these days. But this should be easy enough to try yourself. Grab a Teensy and some mini buttons and give it a whirl–it’s easier than you think (and cheaper!) Good luck!

  2. Hi, im wanting to build one of these myself but am an absolute beginner! how did you mount the teensy into the enclosure, plus I would want to add the jack mounts. can you also help with this?

    1. Hi!
      Don’t worry – this should be manageable for a beginner! Nothing special about the mounting, I just mounted it onto a bit of perfboard so that I could attach wire for the buttons. Jack mounts (in lieu of buttons) would go in the same as the buttons!

  3. Hi,

    I just wanted to let you know I found this article just googling around and it was super helpful building my own foot controller! Thanks for putting it out there!

    I ended up using different code, so when I decided I wanted to do LEDs as well, I ended up just connecting their grounds to each; I’m curious, were there any particular advantages to lighting them up via code vs physical connection?

    Thanks again for the article, it’s a huge help!

    1. Glad to hear it helped somehow!

      I think I went the code route for the LEDs so that they could have other functions (controlled elsewhere), blinking or whatever to give alerts, countdowns etc. If you just need on/off then connecting them direct seems smart.

  4. Hi,

    I’m looking forward to build my own 3 button midi controller.
    Do you recommend the Takachi enclousre? Is this stable/rugged when a footswitch is pressed? My alternative would be a Hammond 1590Z063 but i prefer the dimensions of a Takachi MB5-5-16.

    Regards
    Alexander

    1. The Takachi is okay and certainly good for the price. the only thing I’ll say is that it’s relatively tall and the metal is quite thin, which makes for a rather loud “thock” sound when you press the switches. Would recommend some “silent” switches if building again.

Leave a Reply to oliver Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.