Arduino MIDI controllers - instructions

Thursday January 29, 2015

tags

Arduino

MIDI controllers

Update as of 2/19/17: images are missing from this post, but will be replaced!

If you're interested in how using Arduino for MIDI works, here's how to make the simple controller I described in the previous post. These instructions are based on a number of tutorials, especially Arduino, Sensors, and MIDI. There are many methods of setting up an Arduino for MIDI, but this is what I found to be the most straightforward.

Wiring

First, hook up your Arduino as follows. The squiggly thing in the lower left is the photoresistor, used for pitchbend, and the large circle at the bottom is the push button for note on/off. Red and black cables are for power and ground, while the yellow cables are for sending input values to the Arduino (digital in 7 for the push button, analog in 0 for the photoresistor).

Code

Arduino boards run code written in a modified version of Wiring, which was based on Processing. Copy the following code into the Arduino IDE (adapted from this tutorial):

Verify the code and upload it to your Arduino via the USB connection. Once it's uploaded without errors, it's time for some serial trickery!

Interpreting Serial as MIDI

There are a number of different ways to send the serial information and have your computer interpret it as MIDI, with pros and cons to each. The easiest method is the one I'm using, and the most commonly used in MIDI controller tutorials.

Install a MIDI <-> Serial bridge program, like Hairless. This will interpret serial information coming from a given USB port and output correctly formatted MIDI messages through the selected MIDI output channel. This is easy, and the download requirement is minimal. However, you need to have Hairless running any time you want to use your device, and on low-grade PCs like mine, Hairless will crash if you accidentally send too many MIDI messages at an inhumanly fast rate (happened during testing).

Deconstruct a MIDI -> USB adapter cable, detach all its cable, and use the board to do the converting for you. This requires extra parts, including the MIDI converter, and an extra USB outlet to put in your breadboard. This is a pretty good permanent solution, but in the short term, it costs more money to test and has more moving parts if you're still just starting out.

Write custom drivers. (Not my wheelhouse!)

Install Hairless, and check that the baud rate is set to 9600 in the Preferences. Select the Arduino as your Serial port, and select your desired MIDI out port. MIDI out information depends on your OS. If you're on Windows, the only default MIDI out option will be the Microsoft Wavetable Synth. This is fine for initial tests, but isn't a channel you can select in a DAW. To set new MIDI channels, I installed loopMIDI, which lets you create new virtual MIDI channels that last as long as you are logged in. On Mac, most tutorials say to send MIDI information to IAC Driver Bus 1.

Test!

Open up your desired DAW, and give it a try. The code provided will pitch your note up a half step on each button press; if the pitches get annoyingly high, press the red RESET button on the Arduino board. Changing the light levels in your room or cupping your hands over the photoresistor will alter the pitchbend values sent. The below screenshot shows Ableton with Hairless and loopMIDI up for reference.