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
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