April 28, 2013

A DIY Arduino MIDI Controller with Purpleheart

The Meganome

The Meganome

[Update: Due to the nerd blog media explosion (which is great!), I've had to buy Bandcamp download credits so I can keep giving away my music. If you've enjoyed the videos and music and you'd like to support the creation of future r0b0 beats, you can buy Vio for iPhone and iPad. It's $2.99 and makes your ears feel really good. I use it for the vocals on my EP The Human Element]

A year and a half ago I decided I had to abandon my horn claw MIDI controller. It was a tough decision because there was a lot to like about the controller: gestural control of rhythmic density and beater velocity, zebra wood, and of course, horns. That controller is the first, and as far as I know, only device to put dead springbok into the service of beat-making, a distinction that has earned it pride of place on my bookshelf of discarded electronics. But in the end, what mattered was making music live, and the horn claw made that difficult. It monopolized my right hand and didn’t have enough buttons to trigger pitched instruments. Enter the Meganome.

The author, with horn claw and djembe machine.

The author, with horn claw and djembe machine.


Inspired by the monome, which pioneered grid-based minimalist controllers in 2006, the core interface of the meganome is a grid of illuminated square buttons. I wanted buttons that made a definitive “CLACK” when struck, and I found them in Adafruit’s illuminated square arcade buttons. Unlike the famous MPC drum machine, these buttons are not velocity sensitive, but I was able to compensate partly for that deficiency by including a number of continuous controllers, including pressure sensors and endless encoders that control drum and synth velocity. The other continuous controllers include a proximity sensor and an XY joystick–the same model used in the Playstation controller.

Arduino Code

This video shot by Hal Ibaba Lovemelt of Playatta explains how the controller works to direct drum machines and synths better than I could in blog post, so what I want to discuss here is some of the problems I’ve encountered with the Meganome and offer tips to those who want to build something similar. If you are familiar with Arduino, most of the code for the Meganome should be fairly easy to parse. (You can download my code here. Right click and Save As). The code has a DEBUG flag, which you should set to true in order to communicate with the Arduino from the serial monitor. If you’d like the Mega to appear as a USB MIDI device, set the flag to false.

MIDI Communication

Getting the Meganome to function as a plug-and-play USB MIDI controller was tricky but worthwhile because it makes communication with MAX/MSP much simpler and more stabile. Making the Mega or any Arduino appear as a native MIDI device to your computer requires replacing the firmware on the Mega’s ATmega8U2 chip with new, MIDI-capable firmware from MocoLUFA. These two posts will get you started on doing that, but prepare yourself for frustration. Even if you get everything to work properly, every time you want to tweak your code you will have to first replace the MocoLUFA firmware with the original firmware so you can upload a new sketch. Once you’ve uploaded the new sketch, you’ll have to do the firmware switch in the opposite direction to re-enable MIDI communication. This process involves some command line tedium, and I recommend writing down the steps in a document so you don’t have to re-read those blog posts like I did. I’m not responsible if you brick your pricey Mega.

LED Drivers

I used TLC 5940 chips from Texas Instruments to drive the LEDs, and in my experience these chips work great when you’re using only one or two of them. When you start daisy-chaining more than a few chips, however, communication errors between chips occur. With the Meganome, this has the unfortunate side-effect that sometimes LEDs don’t light up when they’re supposed to. As you can imagine, this is especially aggravating during live performance. As a result, I’m going to move to using shift registers to control button LEDs. If you’re interested in using the TLC chip, the Arduino site has a good tutorial.

Shift Registers and Encoders

The shift registers have proven completely reliable in sensing button presses. The only failures to sense button presses have occurred as a result of my sloppy soldering. The Arduino site has a good tutorial on shift using shift registers for digital input.

The encoders from Digi-Key were more temperamental. They sent noisy signals to the Arduino, and code I found in online tutorial failed to suppress it. Eventually, I found a workable solution that involved using capacitors to filter the encoder signal and writing redundant sensing code that does everything it can to make sure it knows which direction the encoder is turning. The filtering circuit is diagrammed in the datasheet, and the sensing code is in the source I posted above.

Future Work

I’ve been inspired by virtuosic performances I’ve seen with Ableton’s Push controller to rethink how I lay out pitch space on the Meganome. The Push controller, another grid-based offspring of the monome, staggers scales across two rows, so one hand can play a triad, which makes playing traditional tertian harmonies much easier. That’s attractive. And I may also condense the drum controls so I can play all of the machines from one mode, instead of switching from one mode for bongos, djembe, and drum kit, and another for bells and shakers. Finally, wheels for the case. The meganome’s purpleheart case is beautiful, but it isn’t doing my back any favors. It’s that or build robot roadies.

Comments (9)

[...] Patrick Flanagan’s fantastic monome inspired, grid-based MIDI controller, the Meganome: [...]

[...] I did a blog post on difficulties I encountered while building it and posted my Arduino code on my blog: http://jazarimusic.com/finally-a-diy-midi-controller-with-purpleheart/ [...]


April 29th, 2013 at 9:49 am    

Have you considered using a Teensy instead of Arduino? It makes USB MIDI so much easier.



April 30th, 2013 at 8:05 am    

No, I haven’t. But that’s a good idea, and I’d recommend it to anyone starting an Arduino MIDI project. Now that I’ve got the firmware business figured out, I’ll keep doing it that way, but Teensy looks like a great platform for MIDI on Arduino.


May 2nd, 2013 at 2:53 pm    

I’ll second the Teensy recommendation. I’ve been having a lot of fun with that this week. And really, I’ve heard nothing but heartbreak stories from people trying to make MocoLUFA work (but I admire you for sticking with it).

Also, Teensy gives you 12 analog pins right out of the box. As your project expands, it might be worth considering.


May 3rd, 2013 at 5:22 pm    

Robot roadies… you are on to something there! I haven’t wanted to build a robot until now!

lazar woolf

May 5th, 2013 at 5:13 am    

Stop buying download credits. Let me buy an album. TAKE MY MONEY!

[...] I did a blog post on difficulties I encountered while building it and posted my Arduino code on my blog: http://jazarimusic.com/finally-a-diy-midi-controller-with-purpleheart/ [...]

[...] I did a blog post on difficulties I encountered while building it and posted my Arduino code on my blog: http://jazarimusic.com/finally-a-diy-midi-controller-with-purpleheart/ [...]

Leave a reply