Using only an Arduino, a few resistors, a buzzer, and some bits of aluminum foil, you can create your own touch-sensor piano keyboard in just a few minutes! Using an Arduino Uno, you can create a piano with up to 18 keys; or with an Arduino Mega, you can get over 60 keys! Other Arduino boards should work with this project with little to no modification to the code.
Step 1: Parts and Material
[box color=”#985D00″ bg=”#FFF8CB” font=”verdana” fontsize=”14 ” radius=”20 ” border=”#985D12″ float=”right” head=”Major Components in Project” headbg=”#FFEB70″ headcolor=”#985D00″]
You’ll first want to collect all of the parts you will need for the project:
• An Arduino (or Arduino-compatible) microcontroller board.
• Any Arduino board should work: Uno, Leonardo, Mega, Pro Mini, etc.
• Eight 2.2 Megaohm (2.2 MΩ) resistors
• Anywhere between 1 MΩ and 4.7 MΩ should work
• You need one resistor per piano key
• A 2.2 MΩ resistor has a color code of Red-Red-Green or Red-Red-Black-Yellow
• A piezo buzzer
• Some spare wires or jumper cables
• Aluminum foil
• A foot or two should do
• A surface to tape your keys to
• We used a scrap piece of cardboard, but it can be anything you like, even the tabletop itself!
Equipment that you may need:
• Soldering iron and solder
• You can probably get by without an iron by wrapping wires together instead of soldering, but the connection will not be as reliable
• Scissors to cut aluminum foil and tape
Step 2: The Idea and Design
The basic principle behind our method of touch sensing is that each piano “key” is sensor that can measure the electrical capacitance of a person’s body. The measurement will change as the user gets closer to the sensor and will spike dramatically when the user touches the sensor. The Arduino will be looking for these spikes in order to detect when the user has touched the key.
We will need to use one pin an the Arduino for each key as an “input pin”, and we’ll need one pin total to be used as the “common send” pin. We will also need one pin for the buzzer that will be used to generate a tone. This means that since an Arduino one has 20 input pins (14 digital and 6 analog), we can have up to 18 keys on our keyboard! If you have an Arduino Mega or any other board with more pins, that number can be even higher!
Step 3: Create your “Keys”
Out of your aluminum foil, cut a few shapes to be your piano “keys”. Any shape will do, but we took the simple route and made squares. Each key should be somewhere between 2″x2″ and 4″x4″, but most other sizes will work as well.
Step 4: Assemble the Key Circuitry
Each touch-sensitive “key” on the piano is going to require one resistor and two wires/cables. Solder one wire to each leg of the resistor, but make sure to leave part of the leg sticking out. The leg will be used to connect to the foil in the next step. Make as many of these as you plan on having piano keys.
Step 5: Connect the Foil “Key”
Remember the extra bit of leg we saved? Take it and poke it through a corner or side of one of your aluminum foil squares. Fold the leg over the edge back towards itself to make the connect hold more strongly. Go ahead and assemble all of your keys.
For more detail: Capacitive-Touch Arduino Keyboard Piano