The self-playing robotic xylophone has been an on-again off-again project of mine for the last 16 years, and has gone through multiple revisions over that time. If you want all the details of how it first started, and how it finally came to the point where it is now, please keep on reading.
Origin of the Project
The robotic xylophone project goes all the way back to shortly after my wife and I were married, and living in our first one-bedroom apartment in Eden Prairie, Minnesota. Being done with college and having a “banker’s-hours” job during the day, many evenings I just hung around the apartment not doing much. My wife says to me one day, “John, you look bored, you really need a hobby.” During my college years, it seemed that every spare moment was taken up between classes, study, and part-time work, and I had never even thought of the possibility of spending time on something that was fun and enjoyable, that I could do just for myself.
What was it that I should do for a hobby? I really wasn’t interested in hunting, fishing, and football, just like so many other guys. I thought to my college years, and how my favorite class was the Mechanical Engineering Senior Robot Design class, where we used a BASIC Stamp microcontroller, motors, and solenoids to make things move. I also thought of how I enjoyed piano, and was fascinated by the player pianos of many years ago. I would never be able to build a player piano in our apartment.
I could probably get a small xylophone, rig up something with solenoids attached to mallets, connect it to the Stamp microcontroller, and program it to play a song. That first inspiration came to me around the end of 2001.
E-bay, Radio Shack, Ax-Man, and Tinker-Toys
So in early 2002 I started work on the first version of the robotic xylophone. I went on E-bay and found a reasonably-priced 25-note 2-octave xylophone. A 2-octave xylophone turned out to be just right for a project like this. It is large enough, and has both the black and white notes, so that it can play songs with both a melody and a harmony. It was also small enough that it could fit under our bed when not in use. Also, a much larger xylophone would be significantly more expensive.
I then spent around $200 on the Parallax BASIC Stamp 2p40 microcontroller and prototype board. Looking back that was a lot of money considering that our first baby was on the way. Sometimes I cringe to think that today I can buy the much more powerful Arduino Mega for less than $10. Of course, I could never have known that at the time. (It would be about a year later, that a graduate student in Italy would first start working on the development of what would eventually become the Arduino.) I chose the BASIC Stamp 2p40 because it had 32 IO pins, of which 25 could be used to drive the solenoids and play the notes, leaving 7 extra pins to use for pushbuttons or other functions. At the time, I didn’t know about I2C port expanders, etc. The only way I knew of how to drive a solenoid from a Stamp microcontroller, was via a TIP120 transistor.
Finding the solenoids was probably the hardest part of the project. Most of the solenoids I could find on the Internet at the time were $10-$20 each. No, I could not spend $500 on solenoids. However, I has some good fortune when I found some solenoids at Ax-Man (a large surplus store in the Minneapolis area) for only $2 each. I bought all 22 of the solenoids in stock. I made many trips back to Ax-Man to see if they would ever get more in stock, but to no avail. Eventually, I ordered a different type of solenoid online, for the last 3.
Then for the problem of the mallets. I wasn’t going to buy 25 actual xylophone mallets. On the other hand, I couldn’t make them either, as I didn’t have a workshop. I needed something that I could assemble easily, that I could buy at a local store. Then it came to me … Tinker Toys. The round pieces could be the heads of the mallet, and the long pieces could be the handles.
Finally, from Radio Shack, I purchased the transistors and other electronic components, and, to provide enough power to drive the solenoids, a 15 amp, 14 volt DC Power Supply.
Once I had all the pieces, the xylophone from E-bay, the solenoids from the Ax-Man surplus store, the Tinker Toys from Wal-Mart, components from Radio Shack, and the Parallax microcontroller, it didn’t take me to long to create an assembly that could fire 25 solenoids to play 25 different notes.
Piano Music and MIDI Files
Once I had the physical mechanism of the xylophone built, I started thinking, what song should it play? It would be pretty easy to use the Stamp PBASIC code to program a chromatic scale or “Mary had a Little Lamb.” But that wouldn’t be very impressive. Something more complicated, like a Beethoven sonata, would be much more interesting. I could take the sheet music, and program each and every note. But that would be extremely tedious and time-consuming. It would be nice if there would be a way for me to play something on the piano, have it recorded, and then have the xylophone play it back.
We had a Yamaha Clavinova digital piano at that time. I knew that our piano would let me record things and play them back. It also had a 3-1/2 inch floppy drive, which could be used to store recordings. When I put a floppy disk with one of my songs into my computer, I noticed that the files had the extension “mid”. In other words, it was a MIDI file. Somehow, the MIDI file must contain the information for the song that I just recorded on the piano. I did a Google search for “MIDI File Format” and sure enough, I found several hits that told me how MIDI files are divided into tracks, and how tracks are comprised of events, such as Note On, Note Off, and Tempo Change. So all I would have to do is write a simple program to extract the events from a MIDI file and convert them to BASIC Stamp code. Doing this all in my spare time, using Microsoft Visual Basic 6, it took me a few months to write the first prototype of the program to do the MIDI conversion.
I recorded myself playing a song from our church hymnal, and it worked. The same song that I played on the piano, could be played back on the xylophone. Now I had a different problem. I am not all that great of a pianist. Any mistake, a wrong note, or an extra pause, that I played on the piano would be repeated verbatim on the xylophone. I could practice the song for a while, and eventually, it would get better. But it would still not sound as good as a I had hoped. In my mind, I was imagining the xylophone sounding as good as a high school classmate of mine, who wowed people with his talent on the marimba. Even if I could practice the song to perfection, it would be just one song – of which people would get bored pretty quickly.
But then, I realized that people much more musically talented than I are creating MIDI sequences and posting them on the Internet. There are multiple Internet sites out there, each one with hundreds or thousands MIDI files available for free download. Just about any song I could think of, was out there as a MIDI file. It would be far easier to take a MIDI file that someone else has already made, than trying to play and record MIDI sequences myself.
So by 2005, about 3 1/2 years after I first started the project, I had the xylophone playing songs from a MIDI sequences I could find on the Internet. I’m sure there are other people out there who could have gotten the project to that point much faster than I did. But with my wife and I having 3 young kids by that time, there were a lot of other demands for my attention.
Then the project went idle.
Version 1.0: Navigable Menus and Showing it Off
The xylophone project sat idle for the next few years, partly because I wasn’t sure what I should do next, and partly because my attention was going to other more important things in life: family, church ministries, fixing things on our house, etc. Due to some family health needs, 2009 was a year when we suddenly needed to make many major renovations in our house. A lot of things were moved out to the garage in haste, and took a long time to be brought back into the house. One day in early 2010, I was out in the garage cleaning some things up, and I came across a crude plywood box which contained the xylophone. Knowing that I hadn’t even thought about it in a few years, I was pretty close to throwing it away. Perhaps I could salvage the BASIC Stamp and use it for another project. But when I thought about all the hours I put into creating the device, not just the mechanics, but also writing all the software, I knew that if I threw it away, I might not ever build it again. So I decided to keep it.
Nevertheless, in the xylophone’s current state, with only 6 Christmas songs, the not very nice looking plywood box, and how loud it was when songs were playing, it just was not very easy to show off to people. That’s when I decided I needed to make it more presentable … something that I could bring to a gathering of people and demonstrate. To that end, I made several additions:
1.) I found a Parallax 4×20 Serial LCD. This would enable me program a navigable menu, which, when combined with up/down/select pushbuttons, would allow someone to scroll through a list of songs, and choose the one they want to play.
2.) I added external I2C EEPROM memory chips. Now instead of using the BASIC Stamp program memory space for song storage (about 12 KB was available, which could store 5-10 songs, depending upon length), I had 128 KB of available data storage, which could hold 10x the number of songs.
3.) I added the ability to create “Playlists” so that the selection of songs shown on the list could be changed based on the season. For example, I could set it to “Christmas Songs” to use during the Christmas season, to religious songs, if I were to demonstrate this at a church event, or more general songs for use in other settings.
4.) I made a much better-looking enclosure. I mounted the xylophone assembly on a card table (for easy set-up if I were to take it somewhere), and used painted wood board sides, and a plexiglass top, to cover the xylophone. Enclosing the xylophone in wood and plexiglass made it so that it would not be as loud when one was standing next to it.
It was in the Spring of 2011, that I finally had “Version 1.0” of the robotic xylophone complete and ready to demonstrate. I brought it to my church for our end-of-the-year Awana celebration. Needless to say, it got quite a lot of attention. I called it “The One and Only Self-Playing Robo-Xylophone”. Actually, I knew it was not really the “One and Only” because by that time, there were several other people out there who had videos on YouTube of robotic xylophones. But for the average person, this would probably be the only thing like it that they have ever seen. I remember one girl that night asking me how long it took me to build that xylophone, and when I told her I had been working on it on and off for 9 years, her mouth opened wide (A lifetime for her, since she was about 9 years old at the time).
About a year later, I made a video of the xylophone, and posted on YouTube, just to show to friends and family who would not have the opportunity to come over to our house and see it. The video is below.
After posting the video in spring of 2012, and then taking the xylophone to a work Christmas party later that year, I figured that I could be done with this project once and for all, and then move on to other things.
But then …
Arduino and the New Decade
In 2013 I took a job with a new company and moved to Ardmore, Oklahoma. We moved from a 37-year-old house, with no end to the things that needed me to fix, to a brand new house. I went from a job where I was traveling almost every month, to one with almost no travel at all. The children were getting older, and not needing as much attention. I again started to think about what I could do to keep busy in my free time.
At the same time, my oldest son started asking me about wanting to learn electronics and robotics. As I got into the Internet research, I discovered how much the world of electronics and microcontrollers had changed from when I first started the xylophone project in 2002. The most popular hobbyist microcontroller platform was now the Arduino. Compared with the BASIC Stamp, the Arduino had significantly more capability, and depending the source, could be purchased for 1/10 the cost or less. Radio Shack was no longer the go-to place for electronic components (they would file for bankruptcy in 2015). But what Radio Shack lost was more than made up for in all the Internet retailers of electronic parts: Amazon, Mouser, Jameco, NewEgg, MiniInTheBox, and AliExpress.
I found the website for Adafruit, which, besides selling electronics components for a reasonable price, also provided excellent tutorials and videos. If I had never used a certain part or component before, Adafruit gave me exactly what I needed to get started.
I decided to make a “bigger and better” robotic xylophone using an Arduino and other modern components. I also wanted the next version of the xylophone to have better sound quality (after listening to it for 3 years, I started realizing how clunky the Tinker Toys really sounded when striking the xylophone keys.)
In the fall of 2014, I started purchasing the parts I would need to make the “Newer and Greater Xylophone” I bought a 37-note 3-octave Stagg xylophone from Amazon. The most expensive part of the project would still be the solenoids, and again I struggled to figure out where I could purchase almost 40 of these without breaking my bank. I finally settled on the Adafruit Small Push-Pull Solenoid. I also went to work trying to find something better than Tinker-Toys that I could build the mallets with. Eventually, I figured out that I could use dowel rods with round dowel caps, dipped in black PLASTI DIP. I found that coating the mallet head with PLASTI DIP gave a better sound when the it strikes the xylophone note, compared with the bare wood of the dowel cap. I also purchased the top-quality Red Oak boards from Lowes, with the intent of building an enclosure that looked as nice as a new string instrument from the factory.
As I was working hard, trying to get the perfect sound between the Stagg xylophone and the PLASTI DIP mallets, I started thinking, about what should actually be the end result of the project. I could do it just like the original xylophone, where I build it once, just to enjoy for myself, and to show off to the handful of family and friends who come over to my house. But that is a pretty small audience. I could make a YouTube video, just like I did before, and then more people would be able to see it. But the problem there is that it is pretty limited in what I can actually show. I might have hundreds of MIDI songs that have been downloaded into the xylophone, but only a couple of these would actually be shown in the video. And the song that I choose to show in the video is probably not the same one that the viewer wants to hear. For example, in my original video, I play the song “Take Me Out to the Ballgame”. But several people told me afterwards that when they were watching the video, they were hoping I would play the “Star Wars” theme. What I believe makes my project stand out from other robotic xylophone videos that I see on YouTube is the software that allows one to take any MIDI file and play it on the xylophone.
When I would demonstrate the original xylophone, I had various people ask me if I would consider patenting it, or mass producing it and selling it to others. Both sounded like good ideas on the surface, but would be completely impractical to actually do. I knew from my professional work that a well-written patent that would actually protect an invention might cost $50,000 or more. That’s way more than a father of four can do in his spare time, with discretionery spending money. And as for mass-producing, I had probably spent around $1500 over the years to get the xylophone to the point that you see in the video above. Add to that all the hours of labor it takes to put it together, and there is just no possible way that I could build one of them to sell to someone else at a reasonable price. When you can buy an MP3 player for less than $100, and an iPhone under $500, would you actually pay $3000 or more for this big clunky musical machine? Even, as I was working on the next version based on an Arduino and Stagg xylophone, I was figuring I would spend close to $2000. But that was OK, because I was having fun, and I was just going to do it once.
But then, I had a breakthrough …
Build Your Music – The Robotic Xylophone for All
One day, as I was searching the Internet to see if there were any cheaper solenoids out there, I discovered the ZYE1-0530Z 12VDC 1A Push-Pull Solenoid, which I could purchase from NewEgg or AliExpress for as little as $2.50 each. That meant that the cost of the solenoids for a 2-octave xylophone would go from $250 to just over $60. I also discovered that AliExpress had many of the electronics components that I had been using for only a fraction of the cost that I had paid on other websites. I could purchase an Arduino Uno for $3, a 20×4 I2C LCD for $6, and 8-channel motor driver boards for $2 each. For comparison, similar parts on Adafruit would cost $25-$50 each. Granted, the parts that I found on AliExpress were all “knock-offs” or “clones.” But I found all of these to work just as well as the more expensive “genuine” parts.
All of the sudden, the cost of parts and materials to build the xylophone went from $1500 or more, to a little over $200. This is a price-point at which other people might want to purchase and/or build one of these for themselves.
So by the fall of 2015, I completely changed direction. I suspended my work on the “bigger and better” 37-note Stagg xylophone, and put all my effort into the “smaller and cheaper” xylophone, based on the Trophy 25-Note Bell Set and ZYE1-0530Z solenoids. Another focus this go-around was to build the electronics from parts that would not require any soldiering. This would make it much easier to put it together.
I had considered that maybe something like this I could build and sell out of my garage. But even with the ways that I found to make assembly easier, it would be far too labor-intensive to do this on a large scale. A friend of mine suggested that perhaps I could sell a “kit” with all the parts and instructions needed for someone to build the xylophone for themselves. That was a step that might be slightly more attainable. But even selling a “kit” requires one to think through things like supplier quality, inventory, lead times, operations, etc. A lot more than I would be ready to take on.
By early 2017, I finally realized the only practical way to allow the robotic xylophone project to be used and enjoyed by people outside my own small social circle. The way to do this is through what you see on this web-site. By publishing a complete parts list, and vendor list, other people will be able to purchase parts for themselves, at the same price as I can get them. (Much better than me trying to be the middle-man and then having to mark stuff up to cover my costs.) I can publish complete step-by-step instructions and pictures to show everyone else exactly how to build the device. And I would make the Arduino Source Code available for free download on Github.
So that’s Build Your Music – the robotic xylophone that’s not just for me to show off to my friends, but which anyone out there in cyber-space can build for themselves. You Build It. You Choose Your Songs. And You can be the Star of your own Show.
If you are still reading this, and if you are really into the Maker/DIY movement, you probably see a lot of “next steps” and other technologies that one could use to take the robotic xylophone further.
There could be an Android or iPhone app, and Bluetooth connectivity, so that someone could control the xylophone from their phone. (Or for that matter, with an Ethernet shield, the Arduino could connect to the Internet, and the xylophone could be controlled from the other side of the world.)
Someone could design a custom Printed Circuit Board (PCB), rather than assembling components with solderless breadboards.
There is the wide world of 3-D printing. It might be possible to create plans to 3-D print all of these parts, so that one doesn’t need wood-shop power tools and woodworking skills to build the xylophone.
Maybe one day, someone will figure out a viable business model, and offer for sale a product that has pre-packaged all the parts needed to build a robotic xylophone.
But for all of these things, and probably many more enhancements you might think of, I would turn to the Internet community at large. I don’t see myself finding the time to tackle any of this in the near future. I simply feel satisfaction in having put this project out on the Internet for the world to see. Hopefully, others will be able to have as much fun as I have had, and perhaps someone else out there can make this automatic musical instrument even better.