Introduction: Automated MIDI Xylophone

About: Like many people on this website, I like to work with my hands. I've been making things as a hobby ever since I was a kid. My strong points are Circuitry, and Automotive; while I would put my weak point (curre…

In this instructable we will explore how fire solenoids using an Arduino Uno and MIDI signals. One of the best applications for this is to build an automated xylophone. While this is only a guide, the Arduino code and electrical schematics will be provided.

Before trying to tackle this project you should have:

  • Basic woodworking skills
  • Soldering skills
  • An understanding of the Arduino platform
  • A lot of patience.

Parts and materials can be found at the vendor of your choice, but If you're new to the world of electronics it's suggested that you use Adafruit to buy your parts.

Parts list. (Note: Different variances in the xylophone that you purchase may result in needing extra and/or different parts)

Tools list (Note: This project requires wood fabrication and extra woodworking tools are advised.)

  • Soldering Iron
  • Wire Strippers
  • Screwdrivers.
  • Pliers
  • Hot Glue Gun
  • Super Glue
  • Drill.
  • Drill bits. (3/4 inch spade bit and bits for pilot holes)
  • Measuring Tool (I used a straight edge.)
  • Pencil.
  • Jigsaw

Optional Tools.

  • Desoldering Tool (if your new to soldering)
  • Tweezers

Step 1: Wiring the Midi Controller

The first step is to assemble the MIDI controller.

For this you will need:

  • MIDI Jack
  • Arduino Dev. Shield
  • MCP23017 I2C Expansion
  • 6N136 High Speed Optocoupler
  • 1N4007 Diode - x1
  • 470 ohm resistor - x2
  • 1K ohm resistor - x1
  • 10K ohm resistor
  • C1815 NPN transistor
  • Header Pins and Sockets
  • LED
  • Wire

The MIDI circuit can appear intimidating to beginners, but is actually pretty straight forward. If you follow the provided schematic you shouldn't have any issues.

Component placement will be critical. It is easy to run out of room fairly quickly so please use the provided picture of the finished controller as a guide. There are several layouts that will work for this step so if you play around with placement you may find a way that works better for you.

Everything will share a common ground in this project; which will be important in the next step.

Since we're working with a 12 volt power supply, 12 volt solenoids, and 12 volts is within the acceptable range to power an Arduino we can use the same power supply for everything.

If you are new to soldering I strongly suggest that you check out Adafruit's guide to soldering and practice on some perfboard before continuing with this project.

Likewise, if you are new to reading schematics, now would be a great time to do some reading on symbols and polarity. All About Circuits is a wonderful resource for this.

Step 2: Wiring the Solenoid Circuits

Next We'll move on to the solenoid circuit.

    For this step you will need:

    • 1 1N4007 Diode - x16
    • 1K ohm resistor - x16
    • Darlington Transistor or TIP120 transistor - x16
    • Header Pins and Sockets
    • Wire

    The solenoid circuit is much less intimidating. Because these circuits will be pretty small it's a good time to use some scrap pieces of perfboard if you have them lying around. You will need to make 16 of these. In the example photo 4 circuits per board were made and it worked out perfectly.

    Remember to connect the ground wires of your solenoid circuits to the same ground plane that your Arduino is on.

    Everything in the example is modular, so headers and sockets were used to make testing more convenient. However, if you want to save a few dollars you can solder the wires directly into the boards.

    The solenoids that were used in the example came with 2 pin JST connectors from the factory. While no JST ports were handy in my own toolbox, some random right angle connectors coupled with them nicely. Another good use of scrap materials.

    Step 3: Building the Frame

    The third, and biggest step in the process is assembling the frame.

    You will need:

    • 16 key Xylophone Mini 12V
    • 3/4 inch closet dowel - 6ft
    • 3/4 inch plywood or MDF
    • Various wood screws

    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 will provide as much information on the design process as possible.

    First I took the 3 measurements of my xylophone:

    • Height
    • Length
    • Width of low octave side (the widest point)

    I then cut a rectangle out of plywood; the length of your rectangle should match your xylophone's width. The height should give you enough room to lift your xylophone several inches from whatever surface you place it on. It should also give your center bar enough room to house the solenoids and transistor circuitry.

    After cutting my rectangles I cut one of the corners off each to give them a nice shape. This step is optional but if you want to do the same mark 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 (similar to shelf pins). The formula that I used to size the supports is explained below.

    Support Dimensions:

    • 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. 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 center bar is the trickiest and most important part. It needs to be perfectly straight and you will need to leave an almost perfect amount of gap in-between the center bar and the keys. Too much gap and your solenoids won't make contact, too little of a gap and your xylophone won't sound right.

    I cut the center bar to fit snugly in between the two sides of the xylophone. I sanded, measured, and repeated this step until my center bar was as straight as I could make it. 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 it needed to be. I used 2 screws on each side to hold the center bar in place.

    Congratulations, you're finished with the frame!

    Step 4: Placing the Solenoids

    Step 4 is attaching the solenoids to the center bar.

    You will need:

    • Mini 12v Solenoids - x16
    • 4mm m2 size screws - x32
    • m2 flat washers - x32
    • Various wood screws
    • Craft sticks

    How you space your solenoids all depends on your xylophone. I laid a craft stick across as many keys at it would fit over and marked areas where my solenoids would tap the middle of each xylophone key. The spacing ended up being 4 solenoids per craft stick.

    The solenoids used in the example were pre-tapped for M2 size screws. A 4mm M2 screw with a M2 flat washer secured the solenoid to the craft stick perfectly. I pre-drilled the holes for the screws and tightly secured the solenoids to the craft sticks.

    I then cut up a few more craft sticks and glued them to the back of my solenoid arrangement; this did two things. First it spaced the solenoid arrangement away from the center bar enough so the M2 screw heads that were fitted to the back of the solenoids wouldn't sit up against the center beam. Second it gave the solenoid arrangement a more solid connection by providing more material to screw into.

    To attach the arrangement to the center beam I freehanded the spacing by lining up the solenoid arrangement to where I though it should be; manually pushed down on my solenoid plungers to be sure that they would all hit the xylophone keys evenly; and then used small wood screws to attach it to the center bar.

    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. There are many guides on the internet on how to do this and it the process dosen't fit into the scope of this build.

    Once you are comfortable using the Arduino IDE you will need the following Libraries.

    After you have installed those libraries download the code from this instructable and copy and paste into the Arduino IDE.

    Without attaching the MIDI board that you created, upload the code to the Arduino. Once the code has been uploaded hook everything up, press the reset button on the Arduino, and test that everything is working as it should.


    Different xylophones have different note arrangements so the exact code that I wrote might not work correctly for your xylophone. But this is an easy fix. Refer to this MIDI note chart and 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. It isn't very expensive, but it's 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 sound better by releasing the notes prematurely.

    The next important detail is that my xylophone is only 2 octaves of natural notes; meaning that it can't play sharps or flats.

    If you've built this project, please feel free to download the Tetris Theme that I've included on this page.