Introduction: Arduino: Continuous MIDI Controller / KeyBoard

About: I love making and flying RC planes.

This instructable Making a Continuous type MIDI controller / Keyboard is explained. A very simple concept of capacitive sensing is used along with MIDI communication and sound synthesizer software. You may refer Attached video for a quick demonstration or you may refer half-hour-long video to have a detailed understanding of working.

Video on working details:


  1. Arduino Mega
  2. Aluminum Foil
  3. 500 kOhm resistor: 48x
  4. Header pins for Arduino
  5. Soldering Kit

Step 1: Background

Playing continuous notes are very much an integral part of Hindustani music. There is a various expression that required to play such type of notes. There are instruments like Violin, Sitar, or Flute that is capable of doing so. A typical keyboard can only play discrete notes, while In a high-end keyboard a pitch bend wheel is provided that can bend the note to typically 2 semitones on the positive or negative side (this value is adjustable but setting it very high may make difficult to use it with accuracy). This is not a very intuitive way of playing music. There is a various keyboard available in the market like Haken Continuum Board, ROLI seaboard. These are a capable instrument that can do the job really well. More details you may find on the website of the respective instruments.

By inspiring from the mentioned instrument, I tried to make a simple Arduino based touch keyboard previously. more details of it can be found at instructable of the same. This project made use of around 14 nos of plates (low accuracy) and the sound produced using the Arduino tone library. As the sound of it is nothing but a square wave, it is not at all pleasing to hear.

These were the learning from my previous project that I tried to improve on here.

  • Sound generation of Tone library is way too the poor, so here I made use of MIDI massages of quality can be improved,
  • The positioning accuracy of the board was too low due to the bigger size and lower number of plates. Here I almost tripled the number of sensing plates and halved the width of it.
  • The old project also didn't make use of pressure data as the tone library is not capable of modulation volume. Using MIDI opens the door for all such possibility.
  • Capacitive sensing is not a very reliable method. it may get impacted due to earthing, humidity absorbed by the wooden board, and even shoes you were while playing. Here we need to live with this problem as other method makes is either complex and/or expensive.

Step 2: Concept

The overall flow of working goes as follow:


I found two approaches that can be worked upon. One is hall effect sensor-based (used in Haken Continuum board), which is very accurate but relatively complex. this needs some precision mechanism to get the accurate output. However, as mentioned in the previous section (step), the method I found very convenient is to make use of capacitive sensing. If we go for capacitive sensing we don't need any sensor components, we can simply connect metallic plates to the any of Arduino pin and it becomes the capacitive sensor. There is also a library available for Capacitive sensing that can directly be used. More details on the working of this library are available on the above link. In summary, This method checks the time a metallic plate takes to get charged from 0V to 5V via a resistor. This time value represents the capacitance. One more advantage we get is that we can also measure the pressure by using the data. the harder we press, the More area of the finger will come in contact with plates and capacitance will increase. So that's how we will not be having only proximity sensing but we will be getting some number on how hard we press.

Processing the data:

Arduino capture and processes the data. Based on the preset values it calculates the touch positions, pressure values. It also applies the required smoothing to all these values. MIDI messages are nothing but serail messages we need to write. Arduino basically controllers four signals. First to are turning ON and Off any note. another two signals pitch bend and pressure value are continuously calculated and transmitted while any note is ON.

Sound Generation:

Transmitted data from Arduino is used in FL studio to generate the required sound. It needs various software to plug the MIDI signals in FL studio.

Step 3: Preparing the Hardware

The Procedure of making can be directly copied from my previous project. Details are available on my old instructable:

However, there are a few changes that need to be considered while making it. The width of plates is reduced to 6mm (against the previous 12 mm). The reason behind choosing the dimension is that when we touch the surface with minimum pressure the patch created is having a size of somewhere around 8-9mm. so when I touch any key finger will be in contact with at least two plates.

Here I also needed to cover 2 octaves and each key consists of two aluminum foil plates. we need in total of 48 numbers of plates.

Electrical Connection:

As you can see from the above image, each plate is directly connected to the common pin (number 13). It is also connected to an individual pin via a resistor. there is not any restriction on how we connect all these pins to the sensing plate as both analog and digital pin support the capacitive sensing. Based on your connection it is required to modify the code.


While cutting the plates or soldering, you must ensure that all plates are electrically separated from each other.

Step 4: Arduino Software/Code

  1. All plates are declared as a capacitive sensor, all connection needs to be properly mapped on the code. For me pin 13 was the common pin.
CapacitiveSensor   p1 = CapacitiveSensor(13,12); 
CapacitiveSensor p2 = CapacitiveSensor(13,11); CapacitiveSensor p3 = CapacitiveSensor(13,10); . . . CapacitiveSensor p48 = CapacitiveSensor(13,9);

2. Initially capacitance values of all the sensor is captured. The "raw_cap()" function will capture values and store in a globally declared array.

void raw_cap()
{ raw[1]=p1.capacitiveSensor(resolution); raw[2]=p2.capacitiveSensor(resolution); raw[3]=p3.capacitiveSensor(resolution); . . raw[48]=p48.capacitiveSensor(resolution); }

3. Once complete data is captured, another function named "data_process()" executes. this not only process the data but also sends the MIDI message to the computer. this Function flows as follows.

  • Key with max amplitude identified,
  • The exact position of touch is calculated considering one key before and one key after the maximum amplitude value. (That's why we need to have finger touched at least two keys at any time).
  • The last 30 values of the key and pressure values are stored
  • If the touch pressure value exceeds a predefined value, Arduino sends data to turn on a note.
  • During the touch is ON, Arduino keeps sending the pitch bend and pressure values.
  • If Key releases, it sends signals to turn off the note.

This code also snaps the key touch. for example you touch at 7.25 (slightly right on key 7), it will play key 7 (pure Note) only. and during that touch session, it will be the base value for slides. This feature enables laying pure notes easily. The absence of this will make it extremely difficult to do the same.

The complete code is available to download. If you are planning t make a similar thing, you might need to spend a good amount of time in tuning up the code and various values (like resolution and touch threshold)

for the understanding of MIDI message you may refer to this link:

Step 5: Sound Generation

There is three software you will require to generate sound:

1. Hairless MIDI: this is serial to the MIDI bridge. whatever data transmitted by arduino has captured by this software.

2. LoopMIDI: this piece of software captures the data from hairlessMIDI and acts as a MIDI device for FL studio (or whatever software you using)

3.FL studio: In the setting of FL studio you might need to select the LoopMIDI as a device. This code by default gives pitch bend between +8 to -8 semitones (default value in software is +2 to -2). This you need to set manually in the setting of the instrument. Apart from that you also need to assign the pressure value to volume.

Step 6: Common Issues

Here is the list of issues that I faced during the development.
  • A very common issue with capacitive sensing is with proper grounding. Sensitivity will increase if the user touches the ground barefooted. sensitivity also increases if we plug the laptop into mains. However, switching ON the charger may add noise to the data. So, if you set a threshold value for some condition it may or may not work for others.
  • connect between aluminum foil is critical and prone get loosen, many time device may misbehave if it gets loosen.
  • Directly touching in the plate, wire or Pin may give completely wrong data and also spoils the sampling rate. while playing, only partially covered by plastic should be used. All exposed metal should be properly insulated to avoid accidental touch.
  • if you paste aluminum foil directly to the wooden block (with a water-based adhesive), it may take a few hours or days to dry completely. In the wet condition, it will give the wrong output as plates are connected to each other via water channels.
Remix Contest

Participated in the
Remix Contest