loading
I just finished building a music box / light show / jewelry box for my friend Sophie. An Arduino compatible microcontroller is used to generate the music box sound and to control the lights. The Arduino code emulates the sound of an old mechanical box which used a rotating drum with tabs that plucked tune metal tines to produce the note. The code is capable of three note polyphony. This is very easy to build for anyone who can read a schematic. Pictures of the build and links to the Arduino sketch can be had at the link below.

http://www.craigandheather.net/celemusicbox.html


Thanks! Also, I have another question; how does the tilt switch work? I just noticed that you glued on a gold cylinder onto the lid of the box. Is that a special material I need to buy? Sorry to bug you with these questions. I'm a total beginner at this.
The tilt switch is just a switch. In one orientation it is off and in another it is on. There is nothing special to buy except the tilt switch itself. When the music box is opened the switch turns on and the arduino see this and starts the music. <br> <br>The switch is available at: https://www.sparkfun.com/products/10289
Hi, I love your project :) I'm actually trying to recreate this, and use different songs in the music box. Where did you get the MidiParser.java to generate the values of the notes?
Hi,<br><br>Hi,<br><br>All the support files are contained in a jar file available here: http://craigandheather.net/docs/musicboxsupport.jar.<br><br>Note this jar is not executable; it is just an archive of all of the support programs. Unjar this file to get at its contents.<br><br>Good luck,<br><br>Craig Lindley<br>
great project! I would like to do something similar using an Arduino Uno. I am having trouble compiling your code, though; I am getting errors about some of the variables not being &quot;declared in this scope,&quot; such as OCR48. Do you know how to fix this?
The problem is the Arduino I used has a different processor than that used on the UNO which has different instructions. The UNO doesn't have fast enough PWM to allow the music box to sound its best. The code can be made to run on the UNO but it would be some work. If you want to see the types of changes required you should download my code from the April Issue of Nuts and Volts magazine.<br><br>Good Luck,<br><br>Craig Lindley<br>
Cool, I'll check out your article. For anyone else that's interested, here's a link: <br> <br>http://nutsvolts.texterity.com/nutsvolts/201204?pg=28&amp;search_term=music%20box#pg28
Sorry to ping you again, but it seems like the musixboxsupport.jar file on the Nuts and Volts site doesn't work. Do you have an updated version?
The jar file is not meant to be executable. It is just an archive of the various java programs that make up the music box support code. Unjar the jar file to get to the different programs.
Thanks for your help. I've started to work on a programmable music box that is based on your code. Here's a video of a prototype: <br> <br>http://www.youtube.com/watch?v=eFyTW3ht7hc&amp;feature=youtu.be <br> <br>I designed my own custom Arduino and am still learning about microcontrollers, but I found that the response of my Arduino is slower than an Uno; when I upload your code to my Arduino, the songs play almost twice as slow as on an Uno. I'm using an external 8MHz crystal on my board; do you think adding a 16MHz crystal like the Uno would get rid of this problem? <br> <br>Thanks for your help!
The crystal is definitely the issue. The timers used in the music box code are driven directly from the system clock which is half as fast as required. Changing the crystal to 16 MHz will solve your problem.
great, I'll try replacing my resonator.
this looks awesome! :O <br> <br>but i don't understand nothing of this kind of stuff (electronics and such things...) <br> <br>but i think i'm gonna try, a friend of mine wishes she had a music box, as i can't find one and the ones i do are too expensive, i'd try this :) and it's better when it's made from us as a gift :) <br> <br>i looked up for the Pro-Micro Arduino microcontroller you used in the site you mentioned, they have two, you used the 5V/16MHz one right? <br> <br>could you somehow provide me/us a step-by-step for the electronic part? i mean, how do you set up the chip to play the musics you want? :x
The 5 volt Pro Micro part is the one you want.<br><br>At the present time the music box plays the three songs that I picked. To make it play other songs you will need to download the music box support jar file from the nuts and volts magazine (nutsvolts.com) website for the April 2012 issue where I wrote about how the music box works.<br><br>The jar file you download is not executable. You must unjar this file to get to the various programs inside. The midi parser is the file you will need to run on a midi file of the song you want the music box to play. The data spit out by the java code must be copied and pasted into the Arduino code and the code recompiled.<br><br>Hope this helps.<br><br>
Got it! I'll have get the hang on those programs xP but thanks :D as soon as i've time i'll put my mind into this <br> <br>thanks alot! <br> <br>(in time, i'll probably be back with more questions :P)
Craig,<br> A nice display.&nbsp;<br> <br> I'm a little confused by your schematic.&nbsp; Where is the power input?&nbsp; (I think I see it now... it is powered from&nbsp;the USB port?)<br> <br> Can you explain the RC network between the 'RAW' pin and the Grounds? (Is it some kind of power conditioning for the LPD8806's?)<br> <br> Thanks!
The RC filter forms a circuit which prevents the electronic PWM noise of the LPD8806s from being feedback to the microcontroller and being audible in the speaker. Without this filter when the LED strip's PWM circuitry is hard at work you will hear a high frequency whine that is very annoying. The noise is greatest when mixing colors as some of the color components are dimmed in relation to others. This filter eliminates this noise almost completely making the music box sound much better. Hope this makes sense.
Perfect sense!&nbsp; Thanks!
Yes this device is powered by USB.

About This Instructable

6,974views

22favorites

License:

Bio: I'm a retired computer programmer, hardware designer and musician.
More by craiglindley:Craig's Modern RGB LED Clock Sophie's Music Box, Light Show and Jewelry Box 
Add instructable to: