Introduction: Automated MIDI Xylophone
In this instructable I will show you how fire solenoids using midi signal and an Arduino. One of the best applications I found for this was to build a xylophone. I will provide my code and schematic so the only things necessary for you are basic woodworking skills, basic soldering skills, and a lot of patience.
*Note: I suggest using Adafruit to buy your parts. They also have a great forum for project help.
Parts list. (It is recommended that you buy a few extra parts just in case)
- 16 key Xylophone (I live in Japan so I found a Kawai 16s for cheap but any straight 16 note xylophone will work.)
- MIDI Jack
- Arduino Uno R3
- Arduino Dev Shield - (not the same one I used but will still work well)
- MCP23017 I2C expander
- 6N136 High Speed Optocoupler
- mini 12V solenoids - x16
- 1N4007 Diode - x17
- 470 ohm resistor - x2
- 1K ohm resistor - x17
- 10K ohm resistor
- C1815 NPN transistor
- C4811 Darlington transistor or TIP120 transistor - x16
- Header Pins and Sockets
- 12V - power supply (solenoids take quite a bit of power, I used a 10A supply)
- LED (I used blue but any color should work fine.)
- 3/4 inch closet dowel - 6ft
- 3/4 inch plywood or MDF
- USB to MIDI interface cord (if controlling from PC)
- 4mm m2 size screws - x32
- m2 flat washers - x32
- various wood screws
Tools list (for this instructable you will do mild fabricating so a decent arsenal of tools will help greatly).
- Soldering Iron
- Wire Strippers
- Hot glue gun
- Super glue
- Drillbits. (3/4 inch spade bit and bits for pilot holes)
- Measuring tool (I used a straight edge.)
- Desoldering Tool (if your new to soldering)
Step 1: Wiring the Midi Controller
The MIDI circuit is pretty straight forward, you just need to follow the provided schematic. Board placement is somewhat critical. It is easy to run out of room fairly quickly so I also provided a picture of my finished controller to use as a guide.
Everything will share a common ground in this project, so keep that in mind for the next page also.
I used my 12v power supply to power both my solenoids and Arduino (through the Arduino's power jack).
If you are new to soldering I strongly suggest that you check out Adafruit's guide to soldering and practice on some perfboard before taking on this project.
Likewise, if you are new to reading schematics now would be the time to do some reading on symbols and polarity.
Step 2: Wiring the Solenoid Circuits
The solenoid circuit is much easier to read and follow. I used some random pieces of perfboard to assemble the circuit. You will need to make 16 of these. I ended up making 4 per board and it worked out fairly well as you can see in the pictures.
You can see that I wanted to keep everything modular so I used headers and sockets for my wiring; however, if you want to save a few dollars you can solder the wires directly into the boards.
The solenoids that I bought came with a 2 pin JST connector. I didn't have any JST ports handy so I found some random right angle connectors that worked well enough for them.
Step 3: Building the Frame
The frame is the first area where you will be mostly on your own. Chances are you will not have the same xylophone that I used and your measurements will be different from mine. But fear not, I can give you tips on how I designed my frame.
First I took the 3 measurements of my xylophone:
- width of low octave side (the widest point)
I then cut a rectangle out of plywood; the width of your rectangle should match your xylophone's width. The height should give you enough room to lift your xylophone several inches and allow your center beam to have enough room to house the solenoids and transistor circuitry.
After I was happy with my rectangle dimensions I cut one of the corners off to give it a nice shape. To do this I marked from where the start of the angle would be flush with the keys of my xylophone and cut to the top center. Both sides should be identical to each other.
I clamped two sides together and used a 3/4 inch spade bit to drill out holes that would allow me to insert my dowel.
After that was finished I cut 2 more pieces of plywood as supports to hold the xylophone (almost like shelf pins). The dimensions are a bit hard to explain in writing so read this next part a few times.
- Xylophone support 1 (Height = 1 inch, Length = Width of low octave side of xylophone)
- Xylophone support 2 (Height = 1 inch, Length = Width of high octave side of xylophone)
I glued and screwed the supports to the frame making sure that they held my xylophone level. When I was happy with that I cut my closet dowel in half and pushed the 2 pieces into their holes. I checked the basic fit of everything and glued it together. After the glue dried I cut the extra pieces of closet dowel off and sanded them flat against the sides.
The top bar is the trickiest and most important part. It needs to be perfectly straight and you need to leave almost a perfect amount of gap in between the top bar and the keys. Too much gap and your solenoids won't make contact, too little of a gap and the sound may be off.
I cut the top bar to fit snugly in between the two sides of the xylophone. I sanded and measured and sanded and measured repeat repeat, until I was happy with how straight it was. I then placed a magazine that was 4mm thick directly on the keys of my xylophone and used it as a guide to hold the center bar exactly where I wanted it. It worked out great. I used 2 screws on each side to hold the top bar in place.
Congratulations, you're finished with the frame!
Step 4: Placing the Solenoids
How you space your solenoids all depends on your xylophone. I laid a Popsicle stick across as many keys at it could fit over and marked areas in the middle where my solenoids should be placed. I got lucky and my spacing worked out to be 4 solenoids per Popsicle stick as you can see in the picture.
My solenoids were pre-tapped for M2 size screws I found that a 4mm screw with a M2 flat washer would secure the solenoid to the Popsicle stick perfectly. I pre-drilled the holes for the screws and tightly secured the solenoids to the Popsicle sticks.
I then cut up a few more Popsicle sticks and glued them to the back of my solenoid arrangement; this does 2 things. First it spaces the solenoid arrangement away from the center bar enough so the M2 screw heads don't sit up against it. And second it gives you a bit more meat to screw into.
To attach the arrangement to the center bar I eyeballed the spacing, manually pushed down on my solenoid plungers to be sure that they would all hit evenly and then used small wood screws to attach it.
Step 5: Coding the Arduino and Understanding MIDI
To program the Arduino you will need to install the latest Arduino IDE and learn how to do some basic things like upload to your Arduino and install Libraries
you will also need the following Libraries.
After you have installed those libraries download the code from this instructable, you should be able to just copy and paste into the Arduino IDE.
Upload the code to the Arduino (preferably with nothing else attached) hook everything up, press the reset button, and you should be good to go.
if you decide to do this with a different xylophone your note placement may be different from mine. But this is an easy fix. Take a look at this MIDI note chart and just change the note number in the Arduino code to correspond with the notes of your xylophone.
For reference, the notes that I have preset are as follows:
- 79 – G
- 77 – F
- 76 – E
- 74 – D
- 72 – C
- 71 – B
- 69 – A
- 67 – G
- 65 – F
- 64 – E
- 62 – D
- 60 – C ----> Middle C
- 59 – B
- 57 - A
- 55 – G
- 53 – F
Step 6: The Music Program
The program that you see in the video is Guitar Pro 6 its not very expensive, easy to use, and can output midi exactly the way I want it to. Another nice feature of GP6 is that you can add staccato to an entire track which helps the xylophone to play better automatically.
The next thing to note is that my xylophone is only 2 octaves of natural notes; meaning that it can't play sharps or flats (I plan on working with a 32 note glockenspiel for my next rendition).
If you end up building this project, feel free to download the Tetris Theme that I included on this page.