Arduino MIDI Expression Pedal

After saving my school stipend and allowance, I was able to buy a Novation MIDI Keyboard. The Novation Keyboard doesn’t produce any sounds. It needs to be connected to a computer with a digital audio workstation (DAW). The keyboard talks to the computer via MIDI. In my setup, my Novation keyboard talks to my computer using the DAW, Ableton Live 9 Lite. The keyboard has introduced me to wide world of digital music production. 

The Musical Instrument Device Interface (MIDI)

MIDI has been around since 1983 and is used to communicate the pitch, velocity, vibrato and clock signals between MIDI controllers, equipped with sensors, and computers to process these sensor signals to produce sound. These days, MIDI has moved beyond producing sound to being used to control entire live productions. Stage lighting and audio all play in sync with MIDI signals. 

My MIDI Pedal

MIDI Keyboards are great but if you want to modulate effects such as filter, sustain, and volume, it gets difficult because both hands need to be playing on the keyboard. This is why we need a MIDI pedal. Since I couldn’t afford my own, I decided to make my own using the pedals from an old PS2 racing controller and an Arduino microcontroller. 

20180815_215448

I found out that the two pedals worked using a potentiometers and springs. I set up a basic arduino Analog I/O circuit that took analog signals and converted them to MIDI commands. This was sent through the USB output port of the Arduino to feed to the Computer. In order for the computer to recognize the Serial data as a MIDI signal, I used LoopMidi and Hairless Midi. 

diagram

Arduino Code

byte pot1cc = 126;
byte pot1command = 1;
byte pot2cc= 127;
byte pot2command = 2;
int mapped;
int mapped1;
int lastmapped;
int lastmapped1;

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  
}

void loop() {
  //Read Potentiometer Data
  int sensorValue = analogRead(A0);
  int sensorValue1 = analogRead(A1);
  
  //Map Potentiometer Data to standard MIDI Value 0-127
  int mapped = map(sensorValue,0,1023,0,127);
  int mapped1 = map(sensorValue1,0,1023,0,127);
  
  //If mapped changed, send MIDI data
  if (mapped != lastmapped){
    sendMidi(pot1cc, pot1command, mapped);
  }
  if (mapped1 != lastmapped1){
    sendMidi(pot2cc, pot2command, mapped1);
  }
  
  int lastmapped = mapped;
  int lastmapped1 = mapped1;
  
  //Set Delay Between data sends
  delay(10);
}

//Send MIDI data through Serial into Hairless Midi
void sendMidi(byte midicc, byte control, byte velocity) {
   Serial.print(midicc);
   Serial.print(control);
   Serial.print(velocity);
}

My Pedals

Total Cost:  450 Php or around 9 USD and great introduction to MIDI.