My very first Arduino MIDI controller

A very short step-by-step tutorial

icoste
3 min readAug 7, 2018

Sources

I read several tutorials about creating a MIDI controller from an Arduino, but couldn’t find one that would fit my exact setup. Therefore, here is my own tutorial on creating a homemade USB MIDI controller with an Arduino on Windows.

This French tutorial, in particular, helped me a lot: https://2froblog.wordpress.com/2012/07/19/controleur-midi-via-lusb-avec-arduino-49/

My setup

I use Windows 10, Ableton Live 10 and an Arduino Uno.

Components and software

I used the Elegoo EL-KIT-001. I can recommend it so… far.

At least 2 of 10K rotary linear potentiometers. They’re super cheap.

Hairless MIDI <-> Serial Bridge that will decode what the Arduino is sending through the USB port.

LoopBe1 that will forward the MIDI signals to Ableton or FL Studio, for example.

The Arduino IDE that will enable the program to be sent to the Arduino.

Wiring

Wiring is easier with a breadboard as on the picture below: put the potentiometers and connect them as described on the picture.

We want the left pin of both potentiometers to be connected to the GRD of the Arduino and the right pin to the 5V of the Arduino. The middle pin will be connected to the A0 and A1 pins of the Arduino.

Program

You can then create a new program inside the Arduino IDE.

int v0 = 0;
int v0_ = 0;
int v1 = 0;
int v1_ = 0;
int threshold = 2;
int int_to_midi_ratio = 1024 / 128;
void SendMidiToSerial (unsigned char word0, unsigned char word1, unsigned char word2) {
Serial.write(word0);
Serial.write(word1);
Serial.write(word2);
}
void setup () {
Serial.begin(57600);
}
void loop () {
v0 = analogRead(0) / int_to_midi_ratio;
v1 = analogRead(1) / int_to_midi_ratio;

if (v0 - v0_ >= threshold || v0_ - v0 >= threshold) {
v0_ = v0;
SendMidiToSerial(176, 42, v0);
}

if (v1 - v1_ >= threshold || v1_ - v1 >= threshold) {
v1_ = v1;
SendMidiToSerial(176, 43, v1);
}
}

Arduino programs use mainly a setup() function that will be called once, and a loop() function that will be called continuously. Out of them, you can declare global variables and functions.

Global variables and functions

Variables are simple: v0 and v1 will read the pins A0 and A1 at every step of the loop. v0_ and v1_ will be buffers for those variables.

To be sure we don’t send data all the time due to signal noise, we choose to have a detection threshold of 2, meaning v0 or v1 get updated only if they differ with their previous value differ by 2 or more.

The SendMidiToSerial function will help us send the whole MIDI instruction to the USB port using the MIDI message format.

The setup() function

The program will send data with the BAUD rate of 57600, so you better be sure the same number is used also for the BAUD rate in the Bridge:

The loop function

Very simple: we convert the integer from the A0 and A1 pins into a MIDI value. If we detect the value as “newer”, we store it and send it.

Connecting everything together

Connect the Arduino with its USB cable.

Send the program to the Arduino (have it verified by the compiler first, to be sure).

Start LoopBe1 (be sure it’s not muted).

Start the Bridge and connect your Arduino Uno to LoopBe1, then set it “On”.

Enable Ableton (or FL Studio, Cubase, whatever you use) to read from LoopBe1.

Your music software should now be accepting MIDI automation using the potentiometers :)

Demo

It works quite well, right? (I know, my computer was dusty).

--

--

icoste
icoste

Written by icoste

Random writer, here to learn.

No responses yet