"This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)"
In this Instructable, I'll be describing the process I used to make a 3D printed Arduino-driven piano!
- 8 220ohm resistors
- 8 110ohm resistors
- 8 switches (I used these micro-switches from Adafruit)
- 1 Capacitive touch sensor
- 1 RGB LED
- 1 Breadboard
- 1 Arduino Uno
- 8ohm 1watt speaker
- 3 2mm metal rods
- 3D Printer
- Project enclosure box
Step 1: Step 1: 3D Part Design
A simple lid for the enclosure to allow room for the keys to move freely up and down without hitting the edges of the lid.
The keys for the piano were designed so that they would rest flat upon the switches, hence why they are angled. I made them hollow to reduce unnecessary 3D filament waste, and it gives the keys a modern look, fitting of an electronic piano. There is a 2.5mm hole in the bottom corner of the keys where the 2mm rod will go through to allow them to move freely up and down.
Step 2: Step 2: Wiring Diagram
This is the control system for the piano. They breadboard is used to hold the R2R resistor ladder which allows each key to output a different voltage. That voltage is read by the Arduino's analog input and it determines which key was pressed.
The RGB LED must be wired into the PWM pins of the Arduino board to be able to control the intensity of the LED.
Step 3: Step 3: Arduino Code
These files must be downloaded and placed into a single folder in order for the Arduino IDE to be able to recognize them as part of a single package.
Piano.ino contains the main setup and loop of the program. The main void loop runs the offFade function found in offFade.ino to fade the LED on and off, and the InterruptServiceRoutine check until it returns true (the touch sensor has been pressed.) The startup function found in startup.ino then runs, which plays a startup jingle and then sets the LED to green. Once startup has completed, the NoteTest function, NoteTest.ino runs continuously until the touch sensor is pressed again. The NoteTest function continuously reads the analog inputs, and compares them against the range of voltages possible for each key. If a key is pressed, NoteTest calls the tone function to play the corresponding note on the speaker. pitches.h is a library of frequencies that the tone function requires in order to play the correct note.
Step 4: Step 4: Assembly
Drill 2mm holes in both sides of the enclosure according to the specifications in the above image. The metal rods will go though these holes, through the holes in the keys and switches and out the opposite side. A hole can be drilled in the lid of the enclosure to hold the RGB LED, and a small rectangle can be cut in the side for the touch sensor. The speaker and breadboard rest on the inside of the enclosure.