Introduction: Arduino Music Box

In this tutorial I present to you the construction of a music box with only a few components and materials that can be found in any home.An easy project that you can customize according to your imagination and the available materials.

The working principle is simple: a piece of opaque paper passes over eight sensors corresponding to the eight basic musical notes. When a paper cut-out passes in front of one of the sensors, it changes its analog output value and the Arduino notices this by generating a tone. The clipping can be longer or shorter, implicitly the length of the tone generated.




Supplies

  1. Arduino Nano
  2. 8xTCTR5000 infrared sensor
  3. Speaker 8...16 ohm
  4. 2xpush buttons (optional)
  5. 8x270 ohm resistors
  6. 8x3k9 resistors
  7. breadboard,wiring
  8. test board
  9. Visuino software
  10. Arduino IDE

Step 1: Schematic Diagram

The electrical scheme is relatively simple. The analog inputs of the Arduino, A0...A7, are connected to one infrared sensor each. The two buttons for changing the tone may be missing.

Step 2: The Code

  • The code is built in Visuino. You can see the 8 "Analog value" components with 3 values ​​each, corresponding to the 3 tone levels: low, medium and high. The "Start" component ensures that when the device is turned on, the medium tone is set.
  • The eight "Compare analog value" components read the levels of the analog inputs of the Arduino A0...A7 coming from the sensors. When one of the components senses a value lower than 0.89, it generates the corresponding tone.
  • The "And" component interrupts the operation of the frequency generator, the "Play frequency" component, when all the sensors have been activated (there is no paper or cardboard over them).



Step 3: Mechanical Construction

  • The mechanical part is easy to do. The construction of the sensor requires special attention, I opted for removing the components from the plastic support and mounting them on a test board. The paper guides are built with what I found around the house, plastic tubes and pieces of hose. For cutting the notes on paper, I was inspired by piano tutorials for beginners on the Internet. You can choose any song you want.

Step 4: Start the Device

After cutting the paper with the desired melody, it is inserted between the two plastic guides. We turn on the device and turn the crank. If the cutouts are done correctly, the machine should play the chosen melody at a speed dictated by the speed of rotation of the crank. I hope you liked my project, for other details I am waiting for you to write to me in the comments section!