How did I come up with the idea of making a music box? With International Women’s Day approaching, QiuQiu said he wanted to give me a gift, and also a big present. QiuQiu made a small bag by himself and asked me to buy some chocolate online (he promised to pay with his pocket money 😊, but this calculation is quite good, most of the chocolate will probably end up in his stomach 🤦♀️). Then QiuQiu also asked me to choose a music box online, which he would give to me. I said I would prefer to receive a gift made by him.
So, QiuQiu started preparing to make the music box.
What functions should the music box achieve?
QiuQiu designed to implement the following functions:
1. Play music.
2. Able to rotate.
3. Background lighting.
With the basic functions designed, the next step is to consider how to implement them?
1. How to play music?
QiuQiu thought of using a buzzer. In previous buzzer studies, he learned that different sounds can be produced by changing the frequency.
2. How to rotate?
QiuQiu thought of the servo motor he used before. Using the servo motor to rotate the national flag, the same principle applies to any object placed on top.
3. What kind of background lighting?
QiuQiu thought of the common cathode RGB-LED light used when making an infrared sensing night light.
The design of the music box is basically complete, and now it’s time to prepare the materials.
Materials for building the circuit:
-
One Arduino Uno mainboard
-
One buzzer
-
One servo motor (with one servo arm and one small screw)
-
One common cathode RGB-LED light
-
One expansion board
-
One small breadboard
-
Several Dupont wires (male to male, male to female, female to female)
Materials for decorating the appearance:
1. A small box to hold the Arduino mainboard and other components.
Found a box that used to hold a phone watch, it’s just the right size and looks good, so that’s it.
2. A small tray installed on the servo motor to hold a small doll.
Found a cap from a bottle that held ink cartridges, it seemed just the right size, so I used it.
3. A small doll placed on the servo motor can rotate.
I looked for several dolls; I initially started with QiuQiu’s favorite Doraemon, but during the experiment, I found that this doll was too heavy and couldn’t be secured properly, easily falling off during rotation. So I switched to a smaller girl doll (which worked very well).
With all the materials prepared, QiuQiu began building the circuit, drilling holes in the box and the bottle cap, which required my assistance.
Since the buzzer, servo motor, and LED light were all components from previous projects, the circuit was easy to set up.
Testing: The buzzer can make sound, the servo motor can rotate, and the LED light can light up, so the circuit is successfully built.
Next, we need to assemble them with the decorative materials. Although sometimes it was necessary to disassemble the circuit to drill through the holes and rebuild it, the overall assembly process went fairly smoothly.
The assembled music box looks pretty good, doesn’t it?
Now comes the big project: to write the program so that the buzzer, LED light, and servo motor work together to present a perfect music box.
Writing the program went relatively smoothly; each component could basically achieve the expected function, but during debugging, we found that sound and rotation could not be achieved simultaneously. After various debugging experiments, we still couldn’t reach the desired effect.
After searching for information, we discovered that Arduino can only implement single-threading; to achieve multi-threading, third-party libraries need to be installed. (QiuQiu has not yet learned about loading third-party libraries, so to achieve the music box’s function quickly, he temporarily gave up loading third-party libraries and will continue research later.) QiuQiu optimized the program under the existing conditions and presented a satisfactory effect, and the music box was completed.
(During the testing process, the Doraemon doll was too heavy and prone to falling off, so it was replaced with this small girl doll.)
Overall effect of the music box:
What do you think? This music box is made quite well, right?
Previously, QiuQiu learned about buzzers, servo motors, and infrared sensing night lights. The knowledge he learned was perfectly utilized in making the music box, summarizing what he learned before.
During the process of making the music box, QiuQiu integrated the knowledge he learned, applying it in practice and enjoying the fun of learning. During this extended winter vacation, QiuQiu learned to explore and research on his own, combining theory with practice, which was the biggest gain. School is about to start, and in the new semester, I hope QiuQiu can continue to learn through play and enjoy the joy learning brings.
More Arduino related content:
[Arduino] Simulated Traffic Light
[Arduino] Flowing Light Exploration Research (II)
[Arduino] Flowing Light Exploration Research (I)
[Arduino] Flowing Light
[Arduino] SOS Signal Light
[Arduino] Servo Motor – Rotating National Flag
[Arduino] Buzzer
Welcome to join the Knowledge Planet: QiuQiu’s Classroom to get Arduino related program source code
(A knowledge planet managed by QiuQiu, where he shares his learning achievements from time to time)
Join the Knowledge Planet:Learn Programming with QiuQiu, get source code for this public account and more programming information
Follow the video account:Teacher Yang’s Programming Classroom, to appreciate more small Arduino works
Follow the public account:Learn Programming with QiuQiu, learn together and make progress together.
Postscript: Receiving such a cool gift on International Women’s Day makes me feel great 😊.
⇩⇩⇩