Sorry, you need to enable JavaScript to visit this website.

Arduino: Create your own touch sensitive MIDI-keyboard/-controller


Did you ever wish to play an instrument and interact at the same time with another instrument? As an example: Your audience is listening to your great guitar playing. But you want to give them more than that: With one touch on a piece of fine cutted aluminium foil you can trigger a MIDI control command and add whatever you like to your musical performance: Loops, drums, keyboards...

With a little trick you even do not have to touch the foil but only have to wave your hand (or feet) above it to start the MIDI control command. Sounds good but is certainly much too expensive? Then you should read further and experience how to build this device with an Arduino.

Building the hardware

You will need the following components to build the touch(less) MIDI device:

  • 1 x Arduino UNO R3
  • 1 x USB cable
  • 1 x computer/laptop running the MIDI software for sound generation
  • some wires
  • a roll of aluminium foil

You can also build your own MIDI out for Arduino as described in another LMP tutorial.

You may replace the computer/laptop with a Raspberry Pi 2 / Odroid-C1 or any other SBC (single board computer). With that solution you can plug the arduino into that SBC and be mobile and take the MIDI device with you wherever you want. How to do this for Raspberry Pi  (thanks to Jeremy) and for Odroid-C1 (only realtime kernel sources and compilation)

Yes, that's really all you need: An Arduino UNO, some wires to connect aluminium foil to it and some software to get it running, of course.

Setting up the software

Install Arduino IDE 1.6.5.

Download the sketch and upload it to the Arduino UNO (see video).

Let's install some midi related software. First insall ttymidi for connecting the Arduino-MIDI-device via USB-serial with your ALSA-midi compatible application. Download and install it as described on the website.

Next install fluidsynth by using the terminal:


sudo apt-get install fluidsynth


You also need aconnect and aconnectgui for alsa connectivity:


sudo apt-get install alsa-utils aconnectgui


Configure pulseaudio not to spawn:


echo autospawn = no > $HOME/.config/pulse/client.conf


and get temporarily rid of it

pulseaudio -k

Connect the Arduino with your computer and start ttymidi:

ttymidi -b 115200 -s /dev/ttyACM0 -v

Show a list of your hardware devices:

aplay -l

which shows for me (on a ODROID-C1+ with HiFi shield)

**** List of PLAYBACK Hardware Devices ****
card 0: ODROIDHDMI [ODROID-HDMI], device 0: SPDIF PCM dit-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: ODROIDDAC [ODROID-DAC], device 0: PCM5102 HiFi pcm5102-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Test if the audio devices are used by another process/program:

lsof /dev/dsp* /dev/audio* /dev/mixer* /dev/snd/*

Start fluidsynth with

fluidsynth --server --audio-driver=alsa -o audio.alsa.device=hw:1 --sample-rate=48000 --gain=0.1 --audio-bufsize=256 --audio-bufcount=32 /usr/share/sounds/sf2/FluidR3_GM.sf2

To reduce latency play with --sample-rate=44100 --audio-bufsize=256 --audio-bufcount=32

To control gain start with --gain=1.

Possible values are from 0.0-5.0

Reasonable values are from 0-5 for headphones and values from 0.1 - 1.0 for amps.

Show the possible incoming connections:

aconnect -i

which shows me

client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 128: 'ttymidi' [type=user]
    0 'MIDI out    

and for outgoing connections:

aconnect -o

which shows me (tymidi -> Arduino MIDI output)

client 128: 'ttymidi' [type=user]
    1 'MIDI in 

and connect the Arduino with fluidsynth

aconnect 128:0 129:0

Get it running

Plug some wires into the A0-A5 inputs and the D2-D13 inputs of the Arduino.

"A" stands for analog input while "D" is the digital one. In our case analog and digital inputs behave in the same way. There is no difference in using them here.

The digital ports D0 and D1 cannot be used for our MIDI device, because the Arduino UNO uses them for RX and Tx which is in fact the serial device which is left untouched here Rx and Tx are simply said responsible for the serial transmission of data. Also the upload mechanism of the Arduino via USB uses Rx/Tx, so it is better to leave it as it is until you know what you are doing.

Be sure that your speakers are connected and ON and that the volume output level is regulated high enough.

If you have not seen any errors you will be able to play your newly created MIDI instrument now.

Touch one wire and you should be rewarded with a first sound from your own created Arduino MIDI device.


By Georg Mill