Introduction: Handheld 6 Note Music Box / Instrument (Easy to Make & Improve!)

Hi there! Inspired by Martin Molin, a member of a Swedish band called Wintergatan, I recently fell in love with music boxes and everything about them. People making songs for music boxes are still using the old-fashioned way of punching the song note for note, hoping the timing would end up working out. Having done this myself, I know it's a tiring exercise and one that could use a replacement. So I ended up thinking on this idea of using infrared line detectors to create a song. This would mean it would only have to read a sheet of black and white printed paper, but could also have different uses like scanning a newspaper for sound output.

Step 1: The Materials

These are the materials I used, but they are very much replaceable. See what suits you best!

- Arduino Uno

- Speaker or Buzzer

- 9v Battery

- 9v Battery Clip

- On / Off Switch

- 6 x QRD1114 Reflective Sensor

- Jumper Cables

- Wooden Box (10 x 15 x 9)

Step 2: The Circuit

Now the circuit is by leaps and bounds the hardest part of this project in my opinion. But don't let that scare you; it's not that bad.

The QRD1114 Reflective Sensor

The reflective sensor is actually two sensors in one. It contains both a sender and a receiver. The sender is the more orange to white bit and the receiver is the blackish, darkish bit. This is why it needs all of its 4 legs connected to the Arduino. The one on the dot on the receiver needs a 10k ohm resistor connected to 5v AND a jumper cable connected to an analog pin on the Arduino. The one diagonally opposite of that one also needs to be connected to 5v but via a 220 ohm resistor. The remaining two legs can be connected directly to the the ground (GND). Installing 6 or more of these is quite a tight fit so I recommend soldering them if you can.

The Speaker

The Speaker is quite easy to connect. Just connect the - pin to ground and connect the + pin to a digital pin of choice on the Arduino. I used pin ~9 for this project.

The Battery

For allowing your Arduino to be powered by a battery, I highly recommend you check out this instructable:

They do an amazing job explaining how to do it. I used this tutorial for my project as well.

Step 3: The Code

Now for the code. This project uses the base libraries already programmed into the Arduino software.

Just extract the zip file and open the folder. You should be able to see two tabs; HandHeldMusicBox and pitches.h. From here you should be good to go!

If pitches.h is not there you can make a new tab by pressing 'shift + ctrl + T' and naming it pitches.h. From there just copy everything in the .txt file into the new tab which should do it.

Step 4: The Music Sheet

For creating the music sheet I made a google spreadsheet called 'Speelpapier' which is Dutch for 'Playing Paper'. You can check it out via this link:

If you wanna make a song yourself, you can by just copying everything in the sheet, or by saving a copy of it to your Drive. If you prefer to use Excel over google spreadsheets you can do that as well by downloading it as an excel file under File > Download As > Microsoft Excel.

Writing in the music sheet is a bit weird at the moment. The notes go from G to E. If you want to play a G on a certain tile, you fill in '1 on the left side that says "ROW OF NUMBERS". Make sure to add a ' in front of the number to make google spreadsheets realize that it's not actually a number but a string that it can use in code.

'1 = G

'2 = A

'3 = B

'4 = C

'5 = D

'6 = E

Have fun making your own tunes.

Step 5: Improving

Now for the most important step: Make it your own!

I've given you the very basic steps to make the handheld music box, how it's time to improve upon the concept. Here are a few tips:

- You can add more sensors by using a multiplexer or another Arduino

- You can try to make some sensors change octaves to get a wider range

- You can add a volume slider or knob

- Add an amplifier to get more sound out of the speaker

- Use an audio library to get wacky sounds, possibly even creating the 'music box' sound.

- Use timer interrupts or a different method to try and get it to play chords as well!

- Edit the music sheet generator file to make it work for you

- Have some form of mechanism that pulls the paper at a set rate.

Best of luck with your project and make sure to let me know your progress, I'd love to hear it.

Arduino Contest 2017

Participated in the
Arduino Contest 2017