Introduction: Easy DIY Arduino Touch Sensor Piano

This mini piano requires no soldering and is very easy to make.

It's a great starter project to get into Arduinos. I had tons of fun making it and playing it once finished!

This project can be completed by anyone, from children to seniors!

I got the inspiration for this project from Julian Ilett's first penny organ video. If you like electronics, and have not seen his amazing YouTube channel, check it out here:

https://www.youtube.com/channel/UCmHvGf00GDuPYG9DZ...

I remade and simplified it so that anyone can build it!

This has gone through several iterations (each looking better than the last) and this is the best one so far!

Step 1: Materials and Tools

First off, gather all your materials and tools!

If you're like me and love Arduinos and electronics, then you might have some of this stuff on hand already.

Arduino Nano

MPR121 12-channel capacitive touch sensor

Passive Buzzer

400 Point Solderless Breadboard

4 10cm Male-Male jumper wires

1.5m 22AWG Solid core wire

12 M3 screws (6mm) and bolts

Laser cut, Hand Cut, or 3D Printed base plate

All the parts and files can be found in a complete kit here for only $16:

https://a2delectronics.ca/shop/project-kits/12-key-touch-sensor-piano-kit/

A2D Electronics only ships to Canada.

You'll also need a few tools to prepare the wires that will attach to the screws.
Wire Stripper

Wire Cutters

Measuring Device (Or just eyeball it)

Needle Nose Pliers (Optional)

Step 2: Add Components to Breadboard

Arduino Nano

Push the Arduino Nano into the left side of the breadboard.

There should be 3 holes above it and 2 holes below it. This is to allow room for the buzzer later.

Make sure that it is as far to the side as it can go, so that you will be able to plug it in.


MPR121 Touch Sensor

Put the MPR121 touch sensor into the other side of the breadboard so that there are 2 holes above and below the module.

Make sure it is as far to the right as possible. The side with pins marked 0-11 (the electrodes / touch points) should be closest to the bottom of the board.


Passive Buzzer

Put the passive buzzer in to the breadboard above the Arduino.

The side of the buzzer marked with a '+' should connect in line with pin D3 of the Arduino, and the other side to the GND pin 2 slots to the right D3. You will need to bend the legs of the speaker in a little bit to make it fit.

Step 3: Arduino - Touch Sensor Connections

The MPR121 uses the I2C protocol to communicate, so we only need 2 wires for communication and 2 wires for power.

Connect each pair of pins below with a jumper wire.

Arduino -> Touch Sensor

3V3 -> 3.3V Power

A4 -> SDA Data

A5 -> SCL Clock

GND -> GND Ground

The MPR121 is a 3.3V device, while the Arduino is a 5V device. Any signal coming from the Arduino (Clock and Data lines) is too much (5V) for the 3.3V MPR121. Ideally, we should be using a level shifter, or at least some resistors to connect these modules, but it is not strictly necessary. The worst that could happen is you destroy the MPR121 and you need to buy another (very rare). It will simply shorten the lifespan of the module a little bit. I have been using it for months, and have had no problems with just directly connecting them.

Step 4: Prepare Wires for Screws

Cut the Wires

Cut the 22AWG solid core wire into 12 lengths roughly 9cm each with the wire cutters.

You can do this with a ruler, but there is a much easier way. The breadboards are 5.5cmx8.5cm, so just line up the wire along the long side of the breadboard, and cut it slightly longer than that! No ruler needed.

Strip the Ends

Strip ~6mm off one end, and ~15mm off the other end of each 9cm wire with the wire strippers.

Make the Loops

Now, we want to make a loop at the end of the wire that was stripped to ~15mm.

This can be done by wrapping it around the screws. Place the screw in the middle of the stripped part, then bend both ends of the wire up. Now, take the shorter end, and push it to bend it around the screw, then take the long end of the wire and finish wrapping it around.

I find that the easiest way to make these loops is to grip the end in a pair of needle-nose pliers, then wrap it around of side of those. The loop should fit over the screw threads, but not over the head - roughly 4mm diameter. I might also design a 3D printable jig to get it just the right size, and perfectly circular every time.

Make sure there is a screw in each loop of wire.

Do this for all 12 wires. These will connect the screws to the touch sensor.

Step 5: Making the Baseplate

The baseplate is not a necessary component to make sound from your piano, but it allows you to easily spread out the keys, and hold everything together.

There are a few ways to make this:

3D Printed Baseplate

Download the STL attached to this step, and print it out. That's it!

I used 0.2mm layers, 20% infill, but use whatever settings work for your printer!

Laser Cut Baseplate

3mm (1/8") Home Depot hardboard, or MDF is the best material to make this piano with.

Download the SVG attached, and use inkscape (or another SVG graphics program) to modify it to be used with your specific laser cutter.

This one will cut out in 2 parts. The board with a hole for the breadboard will get glued on top of the other. Make sure to line up the screw holes and the bolt holes. For the rest of the assembly, the process is the same as the 3D printed version described.

Hand Cut Baseplate

If you don't have access to a 3D Printer or a laser cutter, you can always do this with hand tools as well.

You can use either some 3mm (1/8") Home Depot hardboard, MDF, or just simply use some cardboard of similar thickness.

Download the PDF attached, then glue it to your chosen material. Start by drilling the holes with a 3mm (1/8") drill bit, then cut out the rest of the frame.

For assembly, when you go to attach the screws to the baseplate, just stick the screws through the holes that you drilled, then attach them with a bolt on the bottom.

Step 6: Adding Baseplate and Screws

Flip the baseplate to the backside, and put a bolt in each hexagonal hole.

Then, take each of the wires with screws, and screw it in to the bolt from the front side.

If using a hand-cut baseplate, put the screws in first, then attach the bolts from the other side.

The screws only need to be tightened finger-tight.

Now place the breadboard on the baseplate. You might need to push fairly hard to get it in.

Don't peel the sticky backing off if you want to be able to re-use the breadboard.

Make sure that the pins of the touch sensor labeled 0-11 are facing the screws and wires in the baseplate.

Then bend the wires from the screws and connect them in front of the touch sensor's pins 0-11. Now each screw is electrically connected to the touch sensor, so touching the screws will trigger the sensor.

Step 7: Code!

Now to add the code!

If you bought a kit from the link given, the code is already on the Arduino, but go through this to know what to do!

Arduino IDE

To program the Arduino, you will need to download and install the Arduino IDE. You can find it here.

Drivers

If you are using a Chinese Arduino clone that uses the CH340 USB to serial chip (most of them do), you will also need to download and install additional drivers from here. Yes, if you get a Chinese Arduino, get Chinese drivers.

Libraries

You will need Adafruit's MPR121 library for this project. Go into the Arduino IDE, go to Sketch -> Include Library -> Manage Libraries, and type MPR121 in the search box. You want the first one, by Adafruit. Click on it, then click Install.

We will also use the Tone and Wire libraries that are already included.

Example Sketch

We only need to add 3 lines to the example sketch that comes with Adafruit's MPR121 library. All the changes you need to do are highlighted in the images.

Open the example by going to File -> Examples -> Adafruit MPR121-> MPR121test

See the pictures for details.

Add this line just before void setup():

int Freq[12] = {1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976};

Add this line at the end of the first if statement in void loop():

tone(3,Freq[i]);

Add this line at the end of the second if statement in void loop():

noTone(3);

You can also download a copy of the code that is attached.

Now, you can upload the code to your Arduino.

Make sure you have the right board and port selected, then hit the upload button that looks like an arrow in the top left corner.

Congratulations, your piano is now fully functional!

Power it up, and you should be able to play some tunes.

Step 8: Make It Look Better! (Optional)

To make it look nicer, we can cut all the wires to the exact length needed.

For the wires attached to the screws, remove them from the breadboard, and lay them flat along the breadboard. Then, using your wire cutters, make a mark were they will attach to the breadboard, and cut the wire roughly 5-6mm further.

Strip the wire starting from the mark that you made.

Bend the wire 90 degrees downwards, and put it back in to the breadboard.

To make the jumper wires look nicer, we will need to replace them.

Take the rest of the solid core wire, and strip about 5mm off the end, then bend it 90 degrees downwards.

Take out one end of one jumper wire, and put the solid core wire end you just bent in to the same spot you removed the jumper from. Keep the wire flat against the breadboard, and run it between the touch sensor and the Arduino, and to the other end of the jumper wire. Then make a mark in the solid core wire, and cut it off 5mm further. Strip the end, starting from the mark, then bend it down 90 degrees. Take out the other end of the jumper wire, and put the solid core wire into it's hole.

Repeat for the rest of the wires between the Arduino and the touch sensor.

Now all your wires look amazing!

Thanks for taking the time to read through this project!

If you want to buy a kit to make it, see here:

https://a2delectronics.ca/shop/project-kits/12-key-touch-sensor-piano-kit/

This is my first Instructable, so if you think this deserves it, vote for me in the first time author's contest!

Comments

author
rafaelnfs (author)2017-08-11

thnks i want do but with arduino leonardo and make a dance pad :) thanks for the idea

author

Sounds like a cool project!

author
Swansong (author)2017-07-25

That's neat! I'd love to see a video of how it's played and sounds:)

author
A2D Electronics (author)Swansong2017-07-26

I'm glad you liked it!

I added a video to the first step showing how it sounds.

author
Swansong (author)A2D Electronics2017-07-28

Awesome! Thanks :)

author
A2D Electronics (author)Swansong2017-07-25

I'll post a video tomorrow!

author
DerpyCyclops (author)2017-07-27

Awesome Project!

About This Instructable

1,734views

35favorites

License:

Bio: I love tinkering with Arduinos and other electronics. I am the owner of A2D Electronics, an online store based in Ottawa, ON that is committed ... More »
More by A2D Electronics:Simple PCB Pin Header Soldering ToolEasy DIY Arduino Touch Sensor Piano
Add instructable to: