Introduction: How to Make a Cheap Arduino MIDI Controller
I'm a huge fan of technology and music, but when I decided to start making my own electronic music, I was discouraged by the high price of MIDI keyboards and controllers. After a lot of tinkering, I saw the opportunity to create my own MIDI keyboard using an Arduino Uno and electric paint, for a fraction of the price compared to existing MIDI devices!
In this tutorial, I will explain and show you how to create your own cheap MIDI controller using an Arduino and electric paint. I will show you step-by-step instructions on how to make the prototype board, how to flash your Arduino with the right software and how to connect and use it with electric paint. In the end, you will have build your own MIDI controller with 12 keys, which has the ability to change octaves and has a Control Change Parameter which responds to the height of your hand above the controller. Let's get started!
Step 1: Gathering Materials
Apart from the electric paint and the actual Arduino Uno board, I was able to get all the electronic parts at a local shop in the Netherlands for €3,50. I did my best to link the parts I used in the Amazon store, but by searching for the parts in your own local electronic (internet) shop, you can lower the price significantly.
Also, If you can't find the exact components I used, you should be able to make reasonable substitutions and the MIDI controller should still work (e.g. you could use a slightly different resistor values or leave certain sensors out).
For the electronics, you will need the following:
- 1 Arduino Uno with an usb cable
- 1 jar of Electric Paint
- 1 5x7cm prototype PCB board
- 3 pushbuttons with matching 2.2K ohm resistors
- 1 LED with a matching 10K ohm resistor
- 1 LDR sensor with a matching 4.7K ohm resistor
- 1 mini jumper connector
- 12 2.7M ohm resistors (2.700.000 ohm)
- 30 straight male pin headers
- 12 bended male pin headers
- 12 male-to-female jumper wires
- 12 uncoated paperclips
Besides the nessecary electronics, the following tools may also come in handy:
- Soldering iron and solder
- A wire stripper
- A side cutter
- A third hand soldering stand
- A multimeter
- Some extra wires and/ or thin iron wire
In the following 7 steps, we are going to make a prototype board which can be placed on the Arduino Uno. This will be used as a simple interface to connect the electric paint and to modify certain MIDI settings.
NOTE: During the remainder of this Instructable, I will refer to the prototype board as PCB.
Step 2: Soldering the Headers
The first step of creating the PCB begins with soldering the headers in the right place. Start by placing the 90° bended headers in the center of the first row on the PCB board, as seen in the first image. These pins will later act as touch sensitive pins to which you can connect the electric paint.
After inserting the headers in to the PCB slots, you might notice that the pins stick out on the bottom of the PCB. To solve this, push them back a little, while firmly pressing the black plastic guiders to the PCB. This ensures the pins are flush with the PCB. Now solder the pins from the bottom of the PCB and make sure no connections touch each other.
NOTE: Do not apply too much heat for too long on the pins, otherwise they get very hot and melt the plastic.
For the second step, place all the straight headers into the slots on your Arduino, like in the second image. Now for the tricky part, place the PCB on the headers inserted in to the Arduino. You might notice that this action requires a little bit of force and that the pins do not align perfectly in the slots of the PCB, as seen in the third image. Unfortunately, Arduinos are not designed with the use of PCBs in mind, but there is nothing we can do about it ;)
After you succeeded putting the PCB on the headers, make sure the pins are flush with the top of the PCB and solder them from above. Now you should have a nice prototype board which can be placed on and be taken of the Arduino Uno.
Step 3: Soldering the Pads/ Traces
Now remove the PCB from your Arduino and flip it on its back, like in the first image. In this step we are going to make pads/ traces to which we can later add components. There are two ways of doing this:
- Fill in all the needed holes with solder to form a trace and connect them to each other
- Make use of thin (iron) wire
I advise using the second method, since it is easier and quicker to do. If you choose this method, follow the layout of the wires on the PCB in the second image. A red dot means you should solder the wire on that spot. A yellow dot means that you should connect the thin wire to the headers on the other side of the PCB, like in the third image. (As you can see, I messed up a little on the lower left corner of the PCB when applying to much solder, be careful with that!)
TIP: If you don not have any thin wire, cut the legs of some used resistors to use them as traces!
Step 4: Soldering the Capacitive Touch Resistors
It is time to install the components which will give this project its main functionality, namely the 2.7M ohm resistors which will provide the touch capacitive functionality.
NOTE: If you want to learn more about the theory and applications of capacitive touch sensors, I advise you to read the following tutorials:
Place one 2.7M ohm resistor underneath the most right 90° bended header pin and push the legs through the holes, like in the first image. Now flip the PCB and push the one leg of the resistor back in the next hole, as can been seen in the second image. Solder the lower leg of the resistor to the PCB hole and the upper leg of the resistor to its assigned header pin and attach a 7cm wire to the header pin, as can been seen in the third image.
Repeat this process until all resistors and wires are soldered in place. The lower legs of the resistors should form one long connection.
TIP: Choose an alternating colour scheme for your wires, this will make them easier to connect in the following steps.
Step 5: Soldering the Pushbuttons
Now for the tricky part, soldering the pushbuttons, LDR and LED.
Start by placing the pushbuttons and resistors on the PCB like in the first and second image. In my example I am using 2.2k resistors, but any resistor with a value between 2k and 10k ohm will work.
Flip the PCB and solder everything in place. Image 3 explains the various connections you should make: a blue dot represents a leg of a pushbutton that you should solder to the PCB, a pink dot represents a leg of a resistor that you should solder to the PCB, a red trace means you should solder the two points it is connected to. And a black trace represents a wire that goes from one leg of the pushbutton through a hole on the PCB, which then connects to a header pin on the other side.
If all soldered correctly, the two most left buttons allow you to change the octave of your MIDI messages, while the most right button allows you to activate the LDR sensor.
Step 6: Soldering the LDR and LED
If the pushbuttons are in place, continue with installing the LDR and LED and the matching resistors.
Before doing this, it is wise to experiment with the resistors value that goes with the LED. In this example, I have chosen for a 10k ohm resistor, so the LED will not be too bright during the night. It might be possible that a 10k ohm resistor is too high for your specific LED to be switched on. Experiment a bit in order to find the right resistor value which provides a brightness you like.
TIP: Anywhere between 330 ohm and 5k ohm should be good resistor value for a 5mm LED.
Now, place the LED, LDR and resistors (4.7K for the LDR, some experimenting required) in the right place. Flip the PCB and solder everything in place. Image 3 explains the various connections you should make: the brown dots represent the legs of the LDR that should be soldered to the PCB, a pink dot represents a resistor leg that should be soldered to the PCB, orange dots represents the legs of the LED that should be soldered to the PCB, a red trace means you should solder the two points it is connected to. And a black trace represents a wire that goes from the resistor leg through a hole on the PCB, which then connects to a header pin.
NOTE: Before soldering the LED, please make sure you get the polarity of the LED right. The positive lead of the LED should connect to the resistor and the negative lead to the ground trace/ pad.
Step 7: Testing All the Connections
Now it is a good time to test whether you successfully soldered the connections of the buttons, LDR and LED. Since this is the final opportunity fix problems, I advise you to upload the test fixture code to your Arduino and let the code run. Like every other file for this project, the code can be found on the GitHub page for this project. Clone/ download the project and upload Arduino_Test_Fixture_Code to your Arduino.
After uploading the code, open the Serial Monitor and follow the steps. If you successfully completed the test fixture, you can move on to the next step. If not, double check the previously soldered connections on the PCB for proper connection or short circuits. A multimeter may come in handy if you experience any troubles.
Step 8: Finalising the PCB
Yeah! This is the final step in creating the PCB for the Arduino. This step is simple, but does require some focus and attention.
Start by inserting the white and green wires into its holes, as seen in the first image (note how we skip the first two holes). This is where the use of two different colours of wires comes in handy.
Now, flip around the PCB and cut the first wire to the right length, as seen on the second image. Then solder it to the header pin which goes into the slots on the Arduino. Repeat the steps for the following wires until you end up with the result as can been seen in the third image.
Your own-made prototypeboard is done! But, before you start using it as your new keyboard and MIDI controller, we first need to test the connections with the provided test sketch. It can be found on the GitHub page for this project. The name is Arduino_Test_Fixture_Code_2. Upload the sketch, open the Serial Monitor and touch the 'touch pins' on the PCB. If you see the text 'Note x is active' for each of the pins when touched, all touch pins are working correctly.
Step 9: Transforming the Arduino in a MIDI Device
Now that your prototype board is done, it is time to transform your Arduino into a real MIDI device which can be detected by music programs, such as Ableton and Fl Studio or even other hardware MIDI devices. This is a two step process:
- Change the current firmware on the Arduino Uno to MIDI compatible firmware
- Upload the MIDI sketch on the Arduino
We start with step one. By default, the Arduino is loaded with usb-to-serial firmware, which allows your Arduino to communicate with your pc and the Arduino IDE. With the new firmware, called DualMoco, we are adding a second mode, which allows your Arduino to act as a native MIDI device.
Let's start with step 1. If you are using MacBook or iMac I advise you to look up the following Instructable on how to change firmware when you're using a Mac and download the right firmware file, which can be GitHub page for this project, in the Firmware folder. Search for the DualMoco.hex file.
For Windows users, you will be using a program called FLIP and follow this tutorial on how to change the firmware on your Arduino. The right hex file can be found on the GitHub page for this project, in the Firmware folder. Search for the DualMoco.hex file.
After uploading the new firmware, reconnect the Arduino to your pc. If everything went successful, your Arduino should not be detected in the Arduino IDE, because of the new software and its current mode (MIDI mode). Open up a music program which is capable of receiving MIDI messages (such as Fl Studio, Ableton Live, Reason, etc. ) to check if the Arduino with the name MIDI/MOCO for LUFA shows up under the MIDI settings, as seen as in image 1.
Step 10: Making Final Preparations
The great thing about the DualMoco is that it has a second usb-to-serial mode, which allows you to upload sketches from the Arduino IDE, just like with the normal firmware! To get your Arduino in this second mode, connect the two of the ISCP pins together, as shown in image 1 and 2. You could either use a simple wire or a small jumper as shown in the images. Now disconnect the USB-cable for a few seconds from your Arduino and reconnect it, your Arduino should show up in the Arduino IDE as usual.
NOTE: When you want to switch to from usb-to-serial modo to MIDI mode, remove the jumper from the ISCP pins as shown in image 3, and reconnect the Arduino to your PC.
Now it is time to upload the actual sketch to your Arduino, called Arduino_Final_Code. As always, the sketch can be found on the GitHub page for this project. Download it, put your Arduino into usb-to-serial mode and upload the code. Verify if everything works by running the Serial Monitor and messing around with various inputs and buttons on the prototype shield. If necessary, fine tune the threshold settings by experimenting with the THRESHOLD and RES values. After everything works as expected, change the following code on line 17, from:
boolean midiMode = false; // if midiMode = false, the Arduino will act as a usb-to-serial device
boolean midiMode = true; // if midiMode = true, the Arduino will act as a native MIDI device.
Now that the final changes are made to the code, it is time to test it with Ableton, Fl Studio or any other music program capable of handling MIDI devices. First we have to switch the Arduino into MIDI mode, to this this:
- Upload the final code to your Arduino.
- Remove the USB cable from the Arduino so it is not receiving any power.
- Switch the Arduino into MIDI mode by removing the jumper on the ISCP pins.
- Plug in the USB cable in the Arduino.
If everything went correctly, open up your music program and start touching some of the pins. Magic sounds should start playing!
Step 11: Soldering the Paperclips to the Jumper Cables
Now that the PCB interface on the Arduino is completely finished, it is time to focus on the electric paint and how it is connected to the interface. There are millions ways of doing this, but I have chosen to use paperclips which slide on the painted paper, since they are easy to get and can be reused.
The proces of soldering a paperclip to the wire is pretty simple:
- Cut off the wire on one side of the cable
- Strip the wire 5mm
- Solder the stripped wire to the paperclip
- repeat till all 12 paperclips are soldered!
NOTE: Make sure the paperclips you use, are made from iron and are not coated with any kind of paint or plastic layer, this will lower the conductivity and makes them useless for the next step.
Step 12: Painting Some Templates
Although it is possible to play the Arduino MIDI keyboard solely by touching the paperclips, it is more fun to paint your own stencils and use them. Since this is a Instructable on how to make a MIDI device on budget, I hand painted a printed stencil, instead of using screen printing methods. The template, as shown in the image above, can be found on the Github page for this project.
Painting the template is pretty straight forward, just make sure you stay between the lines and are using Electric Paint, otherwise it will not work! After the paint has dried, connect the paperclips to each of the notes and you are ready to make awesome music!
NOTE: if you made a nice template (e.g. a drum computer) and you contribute to this project, send it to me so I can add it to the Github page!
Step 13: What's Next?
What's next? Well, start gathering some materials and go make yourself one of these, if you have not done already! Please share your results (video/ pictures/ text) in the comment section, since I am looking forward to see what you are able to create! If you encounter any other problems during the process, do not hesitate to ask for help in the comment section!
Participated in the
Arduino Contest 2016
Participated in the
Epilog Contest 8
1 Person Made This Project!
- 985371 made it!
5 days ago on Step 13
Using Arduino UNO for this kind of projects is not a good choice. Leonardo or Micro have USB native capabilities (ATmega32U4) that enables the board to be used as MIDI device while being programmable at the same time.
Question 2 years ago
Is there a way to sacrifice all buttons, LED and LDR (in order to clear the Analog pins) to add a few more keys on both sides of the main octave?
Question 4 years ago
I in the middle of making a schematic for this project, My aim is to mill out some PCB so the board layout may not be of use to anyone but i'll upload it all somewhere when I am done. Can someone, Bas maybe, check over this for me?
Answer 3 years ago
Is that schematics correct?
5 years ago
Is there any possibility replace this conductive paint with lasers?
5 years ago
Hi! Do you have the schematic of the circuit? I was trying to follow the steps back, trying to reach in a schematic but I've failed due to the number of conections. I intent to prototype it on LPKF S103, and the schematic would help me a lot.
Reply 5 years ago
I don't have a schematic, nor the time to make them at the moment. If you want to make a schematic from the information I've provided in this Instructable, I don't mind to review it and give you feedback!
5 years ago
Please avail us with a schematic. Thank you
5 years ago
I have a blank window when starting the seriel monitor with the Fixture_Code_2
No signals from the capacative sensors
Reply 5 years ago
Hi, are you using a Arduino Uno? Sure that the baudrate in the Serial Monitor matches the one on the Arduino? Did you try to lower the THRESSHOLD and RES settings in the sketch?
Reply 5 years ago
Hey Bas, thanks for that fast respond !! Sorry ... in my first post I forgot to say how much I like your instructable, it's very well documented! This is also the point, why I wonder it does not work for me. I checked everything an I'm pretty sure to have not forgotten anything. The first test (for the buttons) works fine, but the second one still don't work.
I have an Arduino Uno Rev 3, my baudrate is up to 9600 and should be right. I tested also others but no change, I also tried TRESHOLD and RES Settings, still no changes. What can I do now?
Reply 5 years ago
Hello, I just double checked if the sketch was faulty, but it worked fine on my Arduino. I think that either the wiring on the prototype board is faulty, or that something is wrong with your Arduino itself. I suggest that you take a look at the capSense library and try the example sketch. If that works, slowly work your way up to add more inputs. http://playground.arduino.cc/Main/CapacitiveSenso...
I hope this helps, if you have any questions please let me know!
Also, if it works and you make something cool with it, I'd love to see that!
Reply 5 years ago
Hey Bas, it's me again :)
My arduino MIDI Keyboard is still not working and I don't have any clue why. What really makes me wonder is that the first Text Fixture is fine but the second only is a blank window without any signs. I added pictures of my Prototype maybe you can see something I don't see (I really hope so). I could not manage to get the wires through the holes so I put them the way around, this should not matter, right? You mentioned that something with my Arduino may be wrong ... what do you think could be wrong? I installed the USB Frimware which I found in your zipFile then insalled the DualMoco and the Arduino gets noticed als MIDI Device so it seems to work to. But I don't get any Signal.
Thanks for your help and best whises!
Reply 5 years ago
I checked your PCB, it looks fine to me. The DualMOCO firmware has two modes, one for MIDI and one for Arduino IDE communication. When you were testing if the inputs works, were you in the Arduino IDE communication mode? To test this quickly, you could try to add something like Serial.print("hello I am working"); in the setup, and see if this message shows up in the serial monitor.
I also vaguely remember that if one connection is not solid, the rest doesn't work either. So make sure that all connections are conducting energy. Try changing #define numberOfInputs 12 to #define numberOfInputs 1, and see if only one input comes through the serial monitor.
If all of the above doesn't work, your last option is to try a different analog port for the sendPin.
Reply 5 years ago
Hey Bas, sorry for the long delay. Thank you for your detailed help and suggestions. I managed to get 6 inputs working. I checked all connections and all are conducting energy. I soldered some connections again but i can never have more inputs. If I make 7 inputs the LED is blinking and theres no input.
Another problem, as I said the sensors are working for a certain time but after a time they seem to get insensitive. So I have to adapt the threshold. Even if I figure out a certain Threshold which works, I can not get back to it to get it work again. It seems absolutely random and I can not control it.
I connected the Pins with a 6 meter cable and aluminium foil.
Each foil/sensor is 3 meters long and width 5cm hanging from the ceiling.
Another question, you think its possible to give the octave up and down button also a capacitive sensor? How can I manage this? As I said I'm totally noob, sorry for that and many many thanks for this great project and help!
Reply 5 years ago
capacitive sensors are not meant to be used with such long cables and detect areas, especially the Arduino can't really hand this. There exist special touch modules, which work a lot better in this situation (like the mpr121), but these are also a bit harder to program. And even then I'm not sure it will work with such long cables. But it's worth a try!
Here's also a topic with a similar situation as you, you might learn something from it: https://electronics.stackexchange.com/questions/1...
with kind regards,
5 years ago
Great Project. I'm interested in trying this. While gathering materials I noticed "prototype shields" available. I'm assuming it would work in place of making my own. I'm new to this and would greatly appreciate your input on the matter.
Thanks Again for this awesome idea.
Reply 5 years ago
What exactly do you mean with "prototype shields available"? Are you referring to prototypes shields that are specifically made to be fitted on the Arduino Uno?
5 years ago
Is it possible to use another Arduino device? For example, I have several Arduino Nano lying around. Please advise
6 years ago
hello, really nice project,
having problem here at step 8 to upload the test 2, using an aduino uno on mac. Here is the error Im getting:
Arduino_MIDI_controller-master/Arduino_Test_Fixture_Code_2/Arduino_Test_Fixture_Code_2.ino:1:30: fatal error: CapacitiveSensor.h: No such file or directory
exit status 1
Any idea on what I could have done wrong and how I could fix it?