Have you always wanted to play the piano without the bulk and weight of an actual piano? Have you felt the irresistible urge to exert your inner muse in thin air, your hands waving through the air like a conductor, approaching the height of an awe-inspiring crescendo? Neither have we. But we figured it might be fun to make some simple music using a glove, an Arduino, and a mobile phone. The project was part of a TfCD course at Delft University of Technology.
The Palm Piano consists of a wired-up glove which detects currents between your thumb and your four fingers. By tapping your fingers together, or tapping on a conductive surface, the Arduino picks up a signal which it transmits to an Android phone running a custom app. The phone uses these signals to play simple notes, giving you a full half-octave of musical range!
In order to build the Palm Piano, you need the following components:
- A phone running Android and supporting Bluetooth
- Any Arduino or similar microcontroller - examples will use the Arduino Uno
- A suitable Bluetooth module - examples will use the Bluefruit EZ-Link
- A breadboard or soldering materials
- An external Arduino power supply
- Four resistors
- Sufficient jumper wires
- Aluminium foil
- A glove, preferably one you wouldn't mind ruining
You will also require the following software:
- Arduino IDE
- Android Studio or a similar Android development environment
Note: both of these software packages can be downloaded for free.
Step 1: Installing the Arduino Hardware
It's easiest to just hook all hardware into a breadboard. If you want to make your piano more durable, you may want to solder everything together - the connections will have to endure quite a bit of waving around.
The images above give an overview of the Arduino hardware setup. If your Bluetooth model differs in setup from this example, please refer to the instructions supplied by the manufacturer.
- Connect the GND of the Bluetooth module to GND of the Arduino
- Connect the Vin of the Bluetooth module to the 5V of the Arduino
- Connect the TX of the Bluetooth module to RX of the Arduino
- Connect the RX of the Bluetooth module to TX of the Arduino
- Connect the (–) end of the capacitor to the DTR of the Bluetooth module
- Connect the (+) end of the capacitor to the Reset on the Arduino
We'll tell you how to hook up the glove itself up in step 3.
Step 2: Setting Up the Android App
Having taken care of the basic circuitry, it's time to introduce some smartphone magic.
If you do not want or don't know how to create or customise the app, you can get a taste of the project using GloveApplication.apk - simply download the file onto your phone, make sure you have external install files enabled, and install the file. Please note that the project is buggy and very simple, and that we recommend editing the app if you intend to use it for more than a play around.
Making the app yourself
If you want to use our code as a basis for your process, see MainActivity.txt for the Java code, and Main.txt for the corresponding XML. The app has to perform two main functions: listen for any Serial messages over Bluetooth, and interpret those as musical sounds. For the first part, we can use a generic Bluetooth Handler. For the second part, we will create a sound player which uses your preferred set of sounds.
Create an Android app
Simply open your app IDE of choice, and create a new project called GloveApplication. The project only requires a single activity, MainActivity, with a corresponding XML file called main_activity.
The XML file consists of seven vertically alligned elements: one TextView, which is used to display the currently playing note or any relevant Bluetooth messages, two buttons to open and close the Bluetooth communications respectively, and four buttons which can be used to test and/or play with the sound effects.
If you don't want to make this layout yourself, simply copy the contents of 'Main.txt' into the file called "activity_main.xml" in app/res/layout.
The Java code requires four methods: one to find the Bluetooth device, one to listen once the connection is established, one to close the Bluetooth channel if desired, and one to play the necessary audio files. The details of the functions can be found in MainActivity.txt.
The audio files can be any sound fragment of your choosing - this app uses the classical piano notes B, C, D and E - enough to play 'Mary Had a Little Lamb' with some wiggle room. If you intend to build the application yourself, you will need to make a map at app/res/raw/, and supply your own sound effects. We got our files from FreeSound, courtesy of pinkyfinger.
Step 3: Making the Glove
In order to make this glove, place an inch long piece of aluminium foil on the tips of the glove fingers. Take a long piece of jumper wire (long enough to connect to the breadboard and still leave some freedom of movement) and place one end of the wire on or under the aluminium foil. Use duct tape to attach the foil and the wire to the tips of the glove finger as seen in the image.
Alternatively, for a cleaner result, it's possible to make holes in the fingertips of the glove, and insert the electronics into the glove. However, this can be quite tricky to do and may restrict the movement of your hand.
Once the glove is ready, the 5 wires from the glove can be connected to the Arduino breadboard according to the diagram. Remember the wires and their corresponding fingers so that they can be assigned a pin number and sound note accordingly.
Then, simply open your Arduino IDE, enter the code from the text file, upload to your Arduino (either via the Bluetooth module or via a USB cable), and let the program run. Be sure to keep the BAUD rate at 9600 to comply with Android standards.
Step 4: Enjoy Your Career As a Gloved Musician!
Open the app you have created or installed (making sure that your phone is paired with the Bluetooth module), open the comm channel with a press of the button, and start playing!
You can press your thumb to your fingers to play in mid-air, or press it against a metal surface to make a piano out of everyday objects! Let your inner Mozart free, and be sure to let us know if you create any masterpieces.