Inspired by the DIY pressure plate design from both Rich Osgood and Make Magazine, and the Floor Piano Performance, my teammates and I made our own giant wireless floor piano at HackDuke. There are four main components in our wireless floor piano system: the keyboard itself, the main control unit (the Sparkfun box shown in the picture above), the handheld remote, and the receiver connected to the laptop. Below is a communication diagram of the entire system.
The Pressure Plate Keyboard
The basic idea is that each key is a pressure plate made of cardboard, aluminium foil, and foam, and when someone steps on it the two sheets of aluminium foil make contact and close the circuit. We first tried the design from Make Magazine, in which a layer of cardboard is used to separate the two sheets of aluminium foil. It worked well at first, but after a couple stomps the cardboard on the top became bent so the aluminium foil were no longer naturally separated. Another problem is that the cardboard on the top couldn’t return to it’s original position and open the circuit in time ,which means that you’ll have to jump very high in order to play the same note again. So here are the two things I realised after making this first pressure plate: first, the aluminium foil has to be glued to the cardboard surface so that there won’t be an area where it’s slightly bent up and could easily make contact with the other aluminium foil; second, we need to use a different material to separate the two cardboard in order for the top layer to return to it’s original position as fast as possible and also make the pressure plate more durable against heavy stomps.
This is when we realised that foam would be the most suited material for the purpose. As shown in the picture above we made another prototype with four pieces of foam glued to the corners of the aluminium foil on the bottom layer, and it works like a charm!
After we’ve finalised our design for the pressure plate, we immediately started our manufacturing process. Each of my teammates is responsible for one step in the manufacturing process: cutting the aluminium foil to the right size, gluing the foil to the cardboard, and finally putting duct tape around the edge of the cardboard for the purpose of insulation. Then we continued to glue the foams to the cardboard and tape down a piece of wire on each aluminium foil. After each key is fully assembled, we put a piece of LED strip on the top of each key. The reason why we decided to have LED strip on each key is not only that it looks really cool when you’re playing the keyboard, but also that we can have the keyboard teach people how to play it by lighting up the correct LED strip.
Now it comes to the point where we have to make connections between all the keys. In the very first panorama you have seen that our keyboard is split into two parts, the left part with 12 keys and the right part with 13 keys. We want our keyboard to be easy to carry around, so we decided to make it foldable by leaving a space between the E and F, and also some space between the black keys and the white keys.
The Main Control Unit
Each key have four wires coming out of it: +12V and GND for the LED strip, and the input wire and GND for the two aluminium foil. The +12V of all the LED strips are connected together, and the GND of each LED strip is connected to the collector of a TIP120/31/41 transistor. The GND from all the bottom aluminium foil are connected together, and each top aluminium foil is connected to a input pin on the Arduino Mega. Therefore the left keyboard requires a total of 12+1+12+1 = 26 connections, and the right keyboard requires a total of 13+1+13+1 = 28 connections. Since I don’t have any ribbon cable that have that many pins, I decided to make my own cable by taping together 26 and 28 pieces of jumper wires. Here’s a picture of the inside of the main control unit.
All the white wires connected to the male headers are inputs from the top aluminium foil. All the black wires connect to the base of the transistors, and all the colour wires go to the collector of the transistors. All the input pins on the MEGA are pulled high, and once there is a input connected to GND (pressure plate is being pressed), the output to the corresponding transistor would be pulled high and the LED on that key would light up.
The XBee sends note values to the receiver XBee connected to my laptop. A value of 1-25 indicates a note is pressed, and 26-50 indicates that the note is released.
The Remote Control
The remote control is built around an ATtiny85 running at 8MHz. The major functionalities of the remote control are: changing octaves, switching between 16 MIDI channels that are each set to a different instrument, and enter the tutorial mode in which the LED on the keyboard would light up to tell you how to play a song. Using SoftwareSerial, the ATtiny85 is able to talk to the XBee at the 31250 Baud rate, and this XBee then sends the value to the receiver. A value of 51 and 52 moves the octave down and up respectively, and a value between 60 and 75 indicates switching between channel 0 through 15.
The tutorial mode is one of the best features of our floor piano system. Currently, these tutorials are just stored in the form of an int array on the Arduino Mega. To start the tutorial, one presses the white button on the remote control, and a special value would be sent to the receiver connected to the laptop. The receiver then acts as a relay and send this message to the main control unit. After the message is received by the Arduino Mega, the tutorial starts and the first key in the tutorial would light up. In the future we plan to add the functionality to allow people to record tutorials by playing the keyboard instead of storing the note values in the program in advance.
The receiver that’s connected to the laptop is the simplest of all four components. It’s just an Arduino + XBee shield +Xbee. The ATmega8u2 chip on the Arduino is flashed with the MOCO firmware, which converts the serial MIDI data to standard MIDI messages, making the Arduino a real MIDI instrument.
Portability of The System
The entire system is very potable; you can easily carry it around, put it down and start playing anywhere you want. As mentioned above, both of the two parts of the keyboard are foldable in the middle, and optionally between the black and white keys. The jumper wire cable, the remote control, and the receiver can all be stored in the sparkfun box.
Ever since I added the MIDI functionality to my Arduino Piano, I’ve been using the Serial-Midi Converter from SpikenzieLabs as a bridge between my keyboard and Garageband. The software works well, but it is a huge pain having to restart it and go through the setup process every time I connect my keyboard to my laptop. Also, I couldn’t connect my keyboard to my iPhone or iPad, since this software implementation is laptop only. For the past two weeks I’ve been trying to find a better implementation of this serial to Midi conversion and luckily stumbled upon Yoshitaka Kuwata’s Blog. Yoshitaka wrote a serial to MIDI conversion firmware for ATtiny2313 using V-USB, a software-only implementation of a low-speed USB device for AVR micro controllers. Based on the schematic he provided, I made a tiny breadboard-friendly board to fit on my Arduino Piano.
Of all the header pins that plug into the breadboard, there are only three real connections: 5v, GND, and RX on the tiny2313. The tiny2313 receives the serial midi data from my ATmega328 at a standard MIDI baud rate of 31250, and then package the data into real MIDI message and send it to the host device. Using Yoshitaka’s original code, the device shows up as “Baum’s MIDI-controller” when connected to my laptop. If you’re using a Mac, you can find it in the Audio MIDI Setup App. It just feels so great that you can start playing the piano immediately after it is connected to your laptop instead of having to go through the software setup.
For the past week I’ve been trying to find a breadboard friendly DPDT switch to use on my Arduino Piano. After going through Digikey’s catalog a couple times, I realised that there just isn’t any DPDT switch that has the exact 0.1” spacing between pins on the same side, and the 0.3” spacing between the two sides in order to straddle across the gap on a breadboard. Therefore I decided to make my own breadboard friendly DPDT switch.
This DPDT switch I found on Digikey doesn’t have the exact 0.1” spacing, but it’s close enough to be used on a perfboard. We’ll also need two 3-pin headers, and a small piece of perfboard (protoboard, stripboard, whatever you like to call it).
Cut the perfboard down to 4×3 and use a file to smooth out the sides. Then, if you’re not using a perfboard with individual copper pads, use a X-Acto knife to split the copper trace in the middle.Now you can solder on the switch first, and then the two 3-pin headers.
For a long time I’ve been thinking about incorporating the accelerometer or/and the gyroscope into my projects but don’t really know what I want to build. This past week, I realised that I could make another remote control for my RC car using an accelerometer, and immediately started building it. The accelerometer module I used is a MMA8451 breakout. The one shown in the picture is not from sparkfun but has a very similar schematic. I used the example code from sparkfun to read acceleration values from the accelerometer and the corresponding command for the RC Car is sent out using the XBee. I added a 5×7 LED matrix to shown the command currently being sent out in the form of arrows and, if the car is not moving, a circle. You can use the remote in either the landscape mode, which is similar to playing mario cart using the wiimote, or the portrait mode, where every instruction is based on the position of the remote relative to the horizontal plane. I will make a video to demonstrate the full functionality of this remote soon.
About the XBee
The D1 is a 3.3V zener diode with part number 1N4728 (1W) or 1N5226 (1/2W). The MCP1700 is a low dropout voltage regulator and you can find the 3.3V version here. DIN, VCC, and VSS are the only three connections you need to make on the XBee breakout.
On my Arduino piano, the LM386 amplifier circuit has been replaced by a MAX98306 class D amplifier board from Adafruit. This board gives me more control over the gain, and makes the maximum volume much higher given the same supply voltage (3.7V lipo). There was originally quite a lot of noise coming out of the speaker, and for weeks I simply couldn’t figure out where that noise is from. Last week I tried to comment out sections of code and add delays at different places, and see if it has any effect on the noise. Through this investigation, I realised that the noise on the pin of the ATmega328 that is connected to the input of the amplifier is heavily affected by other operations on all the other pins. I soon realised that there is a way to hide these noise from the amplifier instead of removing them. Instead of tying the other input to the amplifier to ground, I connected it to another pin on the ATmega328 that is set to LOW. In this way, the same noise cancels out each other on the two pins, and the output would become very clean.
As I said in a previous post, I added a LED bar graph to the Tetris game to reflect the progress in the game. Currently the setting in the code is that one additional segment on the bar graph turns on for every 5 lines cleared in the game. The setting on the speed at which the piece drops makes it really difficult to go through a total of 50 lines. Also, in order to make the bar graph more lively, I used a timer interrupt to flash the next segment at 1Hz, before it turns solid after the 5 lines are cleared.
Another big change to the layout on the breadboard is that I replaced the 9V battery with two 3.7V 300mAh lipo batteries. This change is not that necessary, but I just don’t want to have any components hanging off the edge of the breadboard.
Now it plays the Tetris theme song while you’re playing! An ATtiny85 is used to store the notes matrix and it listens to the ATmega328p on two pins to either play/stop the music or just pause it. I used the Arduino-Tiny core instead of the one from MIT HLT for the ATtiny85 since it supports the Tone() function in the Arduino library. It was actually quite hard to fit all the frequency values and duration values in a mere 512 bytes of RAM on the tiny85.
Here is a few more components that I’m considering to add to this Tetris game in the future:
-A 3-axis accelerometer (MMA8452Q) to provide another form of input;
-A LED bar graph, or just a couple LEDs, that could reflect the game progress/score.
-A separate small 8*8 or two 5*7 single colour LED matrices to display the next Tetris piece, and to allow the player to store the current piece.