Project tutorial
Turn an Arduino Uno into a MIDI Controller: Guitar Pedals

Turn an Arduino Uno into a MIDI Controller: Guitar Pedals © GPL3+

This foot controller with a Wah pedal, a preset switch and a few extras acts as a regular MIDI controller that works in all DAWs and VSTs.

  • 4,982 views
  • 1 comment
  • 10 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Stereo Jack Female 6.35mm
×2
09939 01
Rotary potentiometer (generic)
×3
SPST Switch (On-Off)
×1
M-Audio EX-P Expression Pedal
×1
Lead Foot FS-2 - double foot switch
×1

Apps and online services

About this project

When I was looking to buy a MIDI stomp box with a Wah pedal, I was a little taken aback by the price. Decent ones sell for 200-300 Euro. After some online digging I found out that it's relatively easy to build one yourself for a fraction of the cost. This Arduino-based MIDI controller cost me around 40 Euro, including a seperate Wah pedal and foot switch.

It's pretty easy to put together. I think the hardest part is flashing the firmware of the Arduino Uno to change the USB connection from a serial communications port to a sound, video and game controller in Windows (I have not tested this on a Mac). Note: I used the HIDUINO project. Not all boards are compatible. From their GitHub page:

The HIDUINO project provides firmwares, documentation, and example code for building a class-compliant USB-MIDI device from an Arduino UNO or Mega 2560. HIDUINO does not use middleware software to convert serial messages through a MIDI loopback port (like LoopBe1 on Windows or IAC on OSX). Instead, HIDUINO provides a true USB-MIDI device for plug-and-play compatibility on Windows, OSX, and Linux - just like a commercial MIDI controller.
HIDUINO takes advantage of Arduino boards where a second AVR chip is used as the USB controller, so it won't work with single chip variants (e.g. Leonardo), nor older boards that use an FTDI chip as USB controller (e.g. Duemilanove). Many cheap Arduino knockoffs that pretend to be an Uno or Mega also might not work, since they tend to use the (slighly) cheaper FTDI chips.

The Sketch

The first thing you have to do is upload the sketch (see code section). Using the MIDI.h library I programmed the Wah pedal, the two foot switches and the three potentiometers and the on-off switch to send MIDI control change messages. These are then recognized in your favourite DAW or VST (like Guitar Rig or Amplitube) and can be programmed to do all sorts of stuff.

After uploading the sketch, it is time to change the firmware of the Arduino Uno. To do this first download:

Then, follow these steps:

  • Make sure the sketch is uploaded to the Uno. After changing the firmware, the Uno is no longer recognized in the Arduino IDE. (This is easily reversible.)
  • Unzip the HIDUINO.zip file. The 'compiled-firmwares' folder is important. The hex files are located there.
  • Install Atmel Flip.
  • Connect the Arduino to a free USB port.
  • Short the two pins (see picture below) with a wire. Now the firmware is erased. You know it worked when the Arduino is no longer recognized as a COM port in the Arduino IDE.
  • Disconnect and connect the Arduino Uno again. Windows will install an unknown USB device.
  • Open Flip
  • Select Device>Select>ATmega16U2. This is the chip on the Uno. There are some versions of the Uno with a ATmega8U2 chip. To make sure you have the ATmega16U2 one, check the chip on the board. (See picture above)
  • Go to Settings> Communications > USB. Select 'Open'. It's possible that it won't open the connection at this point. You then have to install the driver manually. If this is the case, follow the next step.
  • Go to Device manager in Windows and select the Unknown USB Device. Choose update driver and manually locate the driver. It is located at C:\ProgramFiles (x86)\Atmel\Flip 3.4.7\usb. After the installation repeat the previous step. it is now possible to open the connection in Flip.
  • Next, in Flip, go to: File> Load Hex file. Choose arduino_midi.hex in the compiled firmwares folder in the HIDUINO folder you extracted earlier. Choose 'Run'. The new firmware is uploaded.
  • When you connect the Uno now, Windows will recognize it as a MIDI Controller. It is listed as arduino_midi.
  • If you want to restore the regular firmware later, open the hex file Arduino-usbserial-atmega16u2-Uno-Rev3 located at C:\ProgramFiles (x86)\Arduino\hardware\arduino\avr\firmwares\atmegaxxu2\arduino-usbserial

The software part is done. The Uno is now a MIDI contoller.

The Hardware

This part is more straightforward. Connect everything according to the Fritzing drawing:

And put everything in a box:

Code

MIDI Controller SketchC/C++
#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

int analogExpression = A0; //expression pedal
int analogPots[] = {A1, A2, A3}; //pots on top of pedal
int analogPotsOld [] = {0, 0, 0};
int analogPotsNew[] = {0, 0, 0};

int readSwitchNew; //footswitches
int readSwitchNew2;
int readSwitchOld;
int readSwitchOld2;
int readExpressionPedalOld;
int readExpressionPedalNew;

int singleSwitchNew; //single switch on top of pedal
int singleSwitchOld;

//MIDI Control Numbers
#define expPedalCC 50

#define footSwitch1CC 51
#define footSwitch2CC 52

int potsCC [] = {53, 54, 55};
#define singleSwitchCC 56

#define defaultChannel 14

void setup() {
  MIDI.begin (MIDI_CHANNEL_OFF); //start midi
  
  Serial.begin(9600);
  //configure pin 2 as an input and enable the internal pull-up resistor
  pinMode (analogExpression, INPUT);

  for (int x = 0; x <= 2; x++) { //pots
    pinMode (analogPots[x], INPUT);
  }

  pinMode(2, INPUT_PULLUP); //connect to tip //gnd to sleeve. footswitch 1
  pinMode(4, INPUT_PULLUP); //connect to ring footswitch 2

  pinMode (7, INPUT_PULLUP); //connect singleswitch
}

void loop() {

  //read expression pedal
  readExpressionPedalNew = analogRead (analogExpression);
  readExpressionPedalNew = (map (readExpressionPedalNew, 0, 1015, 0, 127));
  readExpressionPedalNew = constrain(readExpressionPedalNew, 0, 127);
  if (readExpressionPedalNew == 126) {
    readExpressionPedalNew = 127; 
  }
  if (readExpressionPedalOld != readExpressionPedalNew) { 

    readExpressionPedalOld = readExpressionPedalNew;

    // send serial value (ControlNumber 1, ControlValue = analogValue, Channel 1)
    // more info: http://arduinomidilib.sourceforge.net/a00001.html
    MIDI.sendControlChange(expPedalCC, readExpressionPedalNew, defaultChannel);
    Serial.println (readExpressionPedalNew);
  }

  //read the Footpedal Switches value into a variable
  readSwitchNew = digitalRead(4);
  readSwitchNew2 = digitalRead(2);

  if (readSwitchNew != readSwitchOld) {
    readSwitchOld = readSwitchNew;

    MIDI.sendControlChange(footSwitch1CC, 127, defaultChannel); 
    Serial.print("Left: ");
    Serial.println("Change");
  }
  if (readSwitchNew2 != readSwitchOld2) {
    readSwitchOld2 = readSwitchNew2;
    MIDI.sendControlChange(footSwitch2CC, 127, defaultChannel);
    Serial.print("Right: ");
    Serial.println("Change");

  }
  //read Pots
  for (int y = 0; y <= 2; y++) {
    analogPotsNew[y] = analogRead (analogPots[y]);
    if (analogPotsNew [y] - analogPotsOld[y] >= 10 || analogPotsOld [y] - analogPotsNew[y] >= 10) {
      analogPotsOld[y] = analogPotsNew[y];
      analogPotsNew[y] = (map (analogPotsNew[y], 0, 1023, 0, 128));
      analogPotsNew[y] = (constrain(analogPotsNew[y], 0, 128));
      MIDI.sendControlChange(potsCC [y], analogPotsNew[y], defaultChannel);
      Serial.print ("pot: ");
      Serial.println (analogPots[y]);
      Serial.print ("potread: ");
      Serial.println (analogPotsNew[y]);
    }
    //read singleSwitch
    singleSwitchNew = digitalRead (7);
    if (singleSwitchNew != singleSwitchOld) {
      singleSwitchOld = singleSwitchNew;
      if (singleSwitchNew ==1) { // is aan
        Serial.println ("On");
        MIDI.sendControlChange(singleSwitchCC, 127, defaultChannel); 
      }
      else {
        Serial.println ("Off");
        MIDI.sendControlChange(singleSwitchCC, 0, defaultChannel); 
      }
         
    

    }
  }

  delay (5);
}

Schematics

MIDI Controller Wiring Diagram
Midi controller foot pedals iezx0sdzo2

Comments

Similar projects you might like

Arduino UNO Guitar Pedal

Project tutorial by electrosmash

  • 47,679 views
  • 27 comments
  • 148 respects

Arduino LED MIDI Controller with FL Studio

Project tutorial by reyadeetopee

  • 1,658 views
  • 0 comments
  • 10 respects

Guitar Speed Pick and Stomp Pedal!

Project tutorial by marc_uberstein

  • 5,088 views
  • 8 comments
  • 30 respects

Cthulhinho: A MIDI Controller

Project showcase by primvla

  • 2,778 views
  • 2 comments
  • 17 respects

MIDI Slide Whistle "MEMIDION" Next Stage

Project tutorial by HomeMadeGarbage

  • 1,651 views
  • 0 comments
  • 12 respects

Arduino MEGA Guitar Pedal

Project tutorial by electrosmash

  • 17,539 views
  • 2 comments
  • 105 respects
Add projectSign up / Login