Arduino Touch Capacitive MIDI Keyboard




Introduction: Arduino Touch Capacitive MIDI Keyboard

About: Design student, wantrepeneur, lifelong learner. Oh, also running a small 3D printing business.

NOTE: I have released a new Instructable on an improved version of this project. It is now capable of handling 12 keys multi-touch input, as well as the option to change from octave. The Instructable can be found here:


This Instructable will show you how to make a touch capacitive MIDI keyboard. If you follow all of the steps correctly, it will work something like this:

Video note: This will not work with normal paint. For this video I used Conductive paint.

What you will need:

- Arduino Uno R3 (this guide is only for a R3, I'm not sure if it will work on other models)
- 12 resistors (somewhere from 1M to 10M Ohm)
- jumper wires
- 11 alligator clips
- some conductive material (electric paint, aluminium foil etc.)
- a software program that can handle MIDI
- touchcapacitive library
- the code & a software file (are provided)

Step 1: Calibrating Touch Sensitivety

firstly, we need to determinate the sensitivety of our resistors. To do this, you will need to download the CapacitiveSensor library and install it into your Arduino folder. Then copy this sketch and upload it to your Arduino.

After you finished uploading the code and building the Arduino, open the serial monitor inside your ADE. If done correctly, you will see a row of values. If you're touching the end of the wire, the send-back value should be higher compared to the value when not touching the wire.

Now it's time to determinate at which value your Touch sensor should 'send' out a midi note. If you're reading a value of 50 when your not touching the wire and a value of 1000 when your touching the wire, you should keep the number around 700 in your head. When you've finished building the touch capacitive keyboard, it will sent out a midi note when the value is over 700.

Now it's time to start working on the actual keyboard..

Step 2: Uploading the Code

It's time to upload the code to your Arduino.

Remenber that value you needed to store in your mind? You need to put that value in the code. Everywhere in the code where stands a 500, you need to change in to your value.

static int lastInput1 = 0;

int newInput1 = total1;

if((lastInput1 < 500) && (newInput1 > 500)) {

for (int note=48;note<49;note++) {//from note 50 (D3) to note 69 (A4)

MIDImessage(noteON, note, ON); }};//turn note on

if((lastInput1 > 500) && (newInput1 < 500)) {

for (int note=48;note<49;note++) {//from note 50 (D3) to note 69 (A4)

MIDImessage(noteON, note, OFF); }};

lastInput1 = newInput1;

After you changed the value the code is ready to be uploaded.

Step 3: Changing the Arduino Software

Now it's time to change the default UNO-dfu_and_usbserial_combined software on your arduino to a MIDI software.

first download the hex file and the FLIP program to upload the hex file to your Arduino.

When you downloaded the file and FLIP, connect your Arduino to your computer. Now it's time to put your Arduino Uno R3 (this will only work on a Uno!) into DFU mode.

Put one wire into the Ground at the top and one to the Ground on the bottom. You need to touch the bottom wire to GND showed on the photo and the top wire to RESET on the photo at the same time. Your Arduino should be into DFU mode now.

Then it's time to upload the MocoLUFA hex file. Open FLIP, select your chip (16u), locate your MIDI.hex file and upload it via USB. Disconnect your USB cable from the computer and connect it again. The Arduino should come up as a MIDI/MocoLUFA device.

remember: When you need to change your ADE code, you need to put Arduino original hex file back. It can be found under C:\Program Files (x86)\Arduino\hardware\arduino\firmwares\atmegaxxu2

Step 4: Building the Circuit

build the circuit as in the pictures.

The end of the wires is where you would touch it. You can attach alligator clips to the ends of the wire so you can clip the wires to alliminium foil for example.

Step 5: Finishing the Midi Keyboard

your Touch capacitive keyboard should be finished by now. It can detect when you're holding a wire and send out a midi note. But we need also a program that can read MIDI and can produce sounds. I would suggest you use a DAW (Fl Studio, Ableton, Logic Pro etc.)

If your Touch capacitive keyboard is working as it should be, it will appear as a normal MIDI device in your DAW as shown. It will work like any normal MIDI keyboard, except that it can only play one note at the time! 

enjoy it!




    • Fix It! Contest

      Fix It! Contest
    • Metalworking Contest

      Metalworking Contest
    • Water Contest

      Water Contest

    43 Discussions


    Question 4 months ago

    Hi, I have problems downloading the code. you can help? thanks

    Works with fruit :)

    Was struggling with uploading the firmware on mac, but I got it working.



    Hey, your new code doesn't work. It only detect the sensor values in void setup(). To keep it detecting, that should be put in the loop() void.
    And I think it's better to use 0 to 11 for the arrays instead of 1 to 12 ,as arrays always start at 0. And your keyboard is supposed to start at middle C, which has the MIDI number 60. If you start the for loop from 1, what you'll get by (60+i) is 61, that means it would be transposed to C#. A great example by the way. Hope it helps!

    Great instructable, love it. If I needed more free pins from the arduino, could I use a shift register or any other IC? Like a 74hc454 or any other?
    Thank you so much!

    1 reply

    I'm not the author of this but I would assume that you can set that up in your DAW.

    ok thanks a lot

    Hi, i found an application call "LoopMIDI" to create a virtual COM port and another application called "Hairless MIDI Serial" to convert Serial input to MIDI, output to serial or input to serial or both. Will this work with your project and code or will i have to change the code. If it would work but you have to change the code, please could you write a code for this.

    1 reply

    I think it should work, however, due to my busy schedule at the moment, you should try it on your own.

    How would you revert arduino to default if you are not using the dualMocoLUFA software

    I would like to know one thing, if you update your arduino to the MIDI software is it possible to reset it to default.

    1 reply

    Hello, it is always possible to revert the software on your Arduino. However, I would advise you to download the dualMocoLUFA software, since this allows you to use your Arduino as a midi device and in normal mode by simply applying and removing a jumper wire. Good luck!

    this instructable is f@^&$#

    i used the updated sensor calibration sketch because the old one didnt work with my mega. i can upload the firmware and see it as a midi device but cannot see any midi output. is there a way i can check its outputting midi before i chage the firmware.


    I'd like to know how you would go about implementing an octave shift up and down buttons or semitone shift? I only need 8 keys which I have implemented already.

    Any help would be great!

    Thanks for the great tutorial! :)

    2 replies

    Note* I only need the 8 keys to play and that would leave 2 keys for the octave shift buttons :)

    You can modify the code a little bit, from:

    sendMidi(0x90, 60 + i, 127);


    sendMidi(0x90, 60 + i + octave * 12, 127);

    where the variable octave will change when you press a button.


    2 years ago

    Great tutorial! I am a total Arduino newbie. I got the code working well. I would like to add MIDI CC1 (modulation wheel) by reading a potentiometer with an analog input. Can you or anyone else help?

    1 reply

    shouldn't be too difficult..

    You need to read the value of the potentiometer and write it to the computer like this: Serial.Write(0xB0, controllerNumber, value/8);