In this Instructables tutorial, I will teach you how to make a simple 8 key piano with your Arduino.
- Arduino Board
- 10MΩ Resistor*8
- Arduino mini box speaker
- (optional) Hot glue gun
Step 1: Gather Supplies
Here is what you’ll need:
- Arduino Board
- 10MΩ Resistor*8 (1MΩ Resistors work too)
- Arduino Mini Speaker
- Double-sided tape
- (optional) Hot Glue Gun
Step 2: Making the Keys
To make the main keyboard, carefully cut out 8 pieces of tinfoil (Mine is approximately 2cm) and cut out a piece of cardboard that could fit these strips of foil. (Making the keys too big may affect its sensitivity and not activate upon press)
IMPORTANT: Do not let the keys touch each other, short-curciting the keyboard
Step 3: Making the Board + Connections
Use a wire and rip off one end of the connection, exposing about 1cm of the copper wires, spread out these thin strands of wires (shown above) to help ensure a better connection when taped to the foil.
Use some double-sided tape and secure the foil strips onto the cardboard, don’t forget to sandwich the copper wires in between (shown above) (Optional) I made cuts into the cardboard to manage the 8 pieces of wires better, however, this is completely based on your preference (does not affect the instrument)
Step 4: Assemble the Circuit
Populate your breadboard and Arduino following the diagram and pictures above:
D2: Captive Sensor (More on that later)
D3~D10: Piano Keys (I used rainbow colours to better clarify each key
Make sure the resistors are plugged into the D2 Bus, in between the wires coming from the Arduino and the wires from the tinfoil.
If you would like to learn more about Captive Sensors: (a method used to detect human touches)
Step 5: Upload Code + Tweaking
Upload the Following Code to Arduino, if your speaker isn’t making sounds when pressed, play around with the threshold level on this line of code
Sometimes the keys are extremely sensitive (playing lots of random noises not pressed) …In that case move the number closer to the 5 digit range
int treshold = (10~30000);
Personally, using the 10MΩ resistors. Values around 5000~7000 all work well.
Step 6: Optional: Making a Cardboard Enclosure
If you have extra cardboard & time left, consider making an enclosure for your creation!
I’m using cardboard but feel free to use anything else other than conductive materials (may affect the keys)
Step 7: Demo + Credits
Using the Keyboard:
Source: Arduino 8 Key Tinfoil Piano