Introduction: Building a Basic Midi Controller Part 1 - Easy 3 Pot (Potentiometer) Arduino Uno Effects Midi Controller (Serial-USB)... Quick,easy and Cheap!

About: My name is Andrew (Andy) and I am currently a student at Leeds Beckett University studying BA (Hons) Product Design at the Leeds School of Art, Architecture and Design. I specialise in design psychology and …

Hello everyone,

I'm relatively new to Arduino and so have been battling my way to make my own midi controllers. There is a huge amount of information dotted around but I couldn't find a simple tutorial for such a simple device; so here it goes.

My original intention was to create a mixer similar to that used with a pair of decks. However, before I move onto that I wanted to make a piece of code which gave accurate and stable readings for potentiometers.

Step 1: What You'll Need!

  • Arduino of any kind, in this case I am using an Arduino Uno.
  • 6 short cables
  • 5 long cables
  • A prototyping breadboard
  • 3 x 10k Linear Potentiometers (the potentiometer should normally be labelled B10K)
  • Hairless Midi Serial Bridge (Software for sending/receiving midi data)
  • LoopBe1 (Virtual Midi Device Software)

Make sure you have all of these before starting.

Step 2: Wiring It Up...

Hopefully you know the basics of circuits. Wire up cables from the positive rail to the positive pin on each of the pots, then do the same for the ground to the ground pins on the pots. The middle pin of each potentiometer is for data, providing an analogue reading from 0-1023. In the code we will use later this value is divided by 8 to give a value between 0-127 which is necessary so that the MIDImessage command works.

Hook up each of the middle pins to analogue pins on the Arduino 0 to 2 (A0 - A2).

Note: If your pots when finishing the tutorial work inversely (clockwise decreases the value and anti clockwise increases the value) then you simply need to switch the ground and power for each pot which should now give you the values rising when turned clockwise and decrease when turned anti-clockwise.

Step 3: Installing the Software...

Install LoopBe1 and Hairless Midi Serial Bridge if you haven't already.

To check that LoopBe1 is running, it should be in the bottom right of your OS (windows) and mute should be unchecked.

Once you have installed Hairless Midi, go into the preferences and set as the image shows. Do not worry about having your Arduino hooked up yet.

Step 4: The Code

Here's the nice bit of simple code based upon an example made back in 2009 by starfiretech. The key adjustments I have made to this code were to check new values against old values, only sending midi data when a change is detected; and the other adding a small delay to remove any slight variations given in value when the pot is not being touched, slightly touched or gets a little knock. Before I added this I was getting some variation (by +/- 1) in value when slightly touched which the delay helps to remove.

int val = 0; //Our initial pot values. We need one for the first value and a second to test if there has been a change made. This needs to be done for all 3 pots.
int lastVal = 0; int val2 = 0; int lastVal2 = 0; int val3 = 0; int lastVal3 = 0;

void setup() { Serial.begin(9600); // Set the speed of the midi port to the same as we will be using in the Hairless Midi software }

void loop() { val = analogRead(0)/8; // Divide by 8 to get range of 0-127 for midi if (val != lastVal) // If the value does not = the last value the following command is made. This is because the pot has been turned. Otherwise the pot remains the same and no midi message is output. { MIDImessage(176,1,val);} // 176 = CC command (channel 1 control change), 1 = Which Control, val = value read from Potentionmeter 1 NOTE THIS SAYS VAL not VA1 (lowercase of course) lastVal = val;

val2 = analogRead(1)/8; // Divide by 8 to get range of 0-127 for midi if (val2 != lastVal2) { MIDImessage(176,2,val2);} // 176 = CC command, 2 = Which Control, val = value read from Potentionmeter 2 lastVal2 = val2; val3 = analogRead(2)/8; // Divide by 8 to get range of 0-127 for midi if (val3 != lastVal3) { MIDImessage(176,3,val3);} // 176 = CC command, 3 = Which Control, val = value read from Potentionmeter 3 lastVal3 = val3; delay(10); //here we add a short delay to help prevent slight fluctuations, knocks on the pots etc. Adding this helped to prevent my pots from jumpin up or down a value when slightly touched or knocked. }

void MIDImessage(byte command, byte data1, byte data2) //pass values out through standard Midi Command { Serial.write(command); Serial.write(data1); Serial.write(data2); }

Step 5: Upload and Setup With Your DAW

If all has been copied correctly or adapted to your needs, the code should upload fine. Make sure you disable Hairless Midi Serial Bridge before trying to upload. You cannot to both at the same time!

Once the code has been uploaded successfully, ensure LoopBe1 is on and startup Hairless Midi serial Bridge.

Set the options as shown with your Arduino on the serial port and LoopBe1 as your midi output.

Next you need to setup the options in your DAW. In Ableton I have put LoopBe1 as a midi input ONLY (this is important as LoopBe1 can only act as either an input or outout in each application, you may get an error if you do and LoopBe1 will be muted. In this case make sure you have the correct settings in ableton as shown, then untick the mute button on LoopBe1) and put the input on remote mode.

Great, If all has worked then you should be able to see the midi input light turn on when moving one of the pots.

Step 6: Midi Mapping

Next map your midi controls to something in the DAW. Here I have inserted a test music track and applied a ping pong delay to that track. I have then assigned the 3 pots to different controls on the ping pong delay. To asign a pot, first click the midi button at the top right of the app. All assignable controls should now turn blue. Next click on the control in the plugin you want to be controlled by one of your pots. Once selected, then move a pot. That pot is now assigned to that control. Repeat for the other 2 pots but controlling different variables on the plugin.

Step 7: The Result

Here's a short video showing it in action.

Since this is my first instructable I'd love some feedback to improve on in the future. Hope this has helped a few of you trying to get to grips with Arduino Midi controller making.

Mind for Design

Participated in the
Mind for Design

Coded Creations

Participated in the
Coded Creations