How to make a box with your own hands from improvised materials. How I made a music box Homemade music box

So it's time to talk about what was inside my box, cut out of plywood with a jigsaw. At the heart of everything was a circuit diagram on the controller, powered by 2 Krona batteries (9 + 9 V). I recorded the music on a 16-32 MB SD card. Moreover, the box played a new melody every time it was opened. Let's start in order!

Element base of the contents of the box

The core of the circuit is the Atmega16 microcontroller, 40-pin, which just controls the playback of melodies. It has a DIP case so that it can be easily inserted and removed from the socket located on the board. The picture of Atmega16 is as follows:

Another equally important microcircuit is the LM4860M 1 W, 16-pin audio amplifier, from the outputs of which the amplified signal goes to an 8-ohm speaker. I took the execution of this microcircuit in the SO16 package.

You will also need 2 microcircuits - a voltage converter: 7805 in the TO-220 package, the output of which is a constant voltage of +5 V, and IRU1117-33 in the SOT-223 package, with a constant output voltage of +3.3 V, from which the SD- map. The image of these chips is below:

To run the controller, you need a 16 MHz crystal oscillator. A 16-32 MB SD card, now it is difficult to get such a small flash card, but earlier they came with some camera models in the kit. All resistors and capacitors are SMD for surface mounting.

Schematic diagram of a music box

The electrical circuit of the box looks like this:

As you can see, out of 40 legs of the microcontroller, only 18 are used. Pins 5 to 8 - exchange with the SD card, 9th - to reset the controller, 10 - power supply + 5V, 11.31 - ground, 33-40 - through a divider to an audio amplifier. The Atmega16 microcontroller needs to be flashed, but not on the board itself, but on a special device connected to the computer via RS-232. The exchange with the computer goes through the SPI interface of the controller (pins 5-8). The firmware is downloaded using the PonyProg computer program. The firmware itself (Music_box_16.hex) and a screenshot of the installed fuses in PonyProg (PonyProg_Mega16_Fuses.bmp) are in the attached archive. Also in it you will find technical descriptions (datasheets) for the used microcircuits and microcontroller.

PCB layout

I did the layout of the tracks on the printed circuit board in the Sprint Layout4 program. Accordingly, the shkatulka.lay file is in the archive. A board with dimensions of 130x70 mm made of one-sided foil-coated getinaks. All SMD resistors and capacitors, the LM4860M chip, IRU1117-33 are placed on the side of the tracks, and the microcontroller, SD card slot, electrolytic capacitors, the 7805 chip are placed on the other side. The PCB drawing is shown below:

To etch the board, I used the old "iron method" and ferric chloride. Then I soldered all the elements, the speaker, the power button and the power supply from two 9 V batteries remained outside the board. Unfortunately, at that time I didn’t have a camera at hand, and I didn’t have such a goal (to capture my work), so I don’t have the opportunity to show the montage I received, and I won’t disassemble the non-separable box. Then I left myself the opportunity only to change the batteries, and rewrite the USB flash drive.

Recording melodies for the box

The SD card needs to be formatted in FAT16. The melodies that you want to be played by the box should be prepared. The total number of melodies is up to 100. Playing time is 1 minute. The audio format is .wav PCM 16 kHz 8 bit mono. Name the files - “ring_00.wav”, “ring_01.wav”, etc.

Archive.7z for download:

Stuffing for a box(5.8 MiB, 281 hits)

OK it's all over Now! Collect, run and enjoy!

P.S. Don't forget to subscribe to the newsletter (-> on the right in the sidebar)!


In the music box, almost at the very bottom, moments of bygone days are quietly sleeping. The once popular accessory is now gathering dust in museums or on mezzanines filled with all sorts of rubbish. So it could have been further, if the designers had not decided to revive the music box, making it a real luxury item. Let's talk about the brightest specimens in our review.



Starting from November, all the screens of the country are filled with a cheerful Santa Claus with a bottle of Coca-Cola in his hands. From year to year, advertising practically does not change, so the main character becomes almost familiar, and in the supermarket, the hand itself reaches for a fizzy drink. Now he has migrated to the lid of the music box. Such Santa Claus, of course, will not bring Coca-Cola, but it will please you with music.


The main thing is a roof over your head. As it turned out, this truth is relevant not only for people, but also for music boxes.


This music box is made to order. The designer not only chooses the melody that the client likes, but also creates figurines-portraits of the birthday or family members of the customer.


Antique stylized music box in the form of a medallion. Designers say that one such gift can win the heart of a girl.


If the capricious charmer remained indifferent to the singing heart, you can try to give her a music box in the form of a carousel. But first you should ask: does the girl love music or is the best gift for her in the jewelry department.


What progress has been made! Manufacturers came up with a music box for the Ipad. To put it into action, you need to download a special application on your iPad, and you can enjoy the melodies.


A music box created especially for the anniversary of the Beatles. However, the cover of the product speaks very eloquently about this. As for the repertoire of the box, it consists exclusively of the songs of the legendary band.


Kids will love this box for sure. Designers periodically change the main characters of the box. One thing remains unchanged - the nature of the product.


Music box for those who write music. Create melodies, fix them on a special card and enjoy the result.


Designers offer to create such a box with songs on their own: paint it in your favorite color, add all kinds of figures, inscriptions and give it to a dear person. After all, the best gifts, as you know, are made by hand. If you can’t make a music box on your own, you can give it to a birthday person. I'm sure anyone will love this gift.

Music boxes are ordered from time to time. This is a good memorial gift. After all, each couple has its own melody? This is the box I want to talk about.


In general, there is a desire to create my own mechanism for this business, but for now I use the famous kikkerland 15. It has 15 voices and the melody itself is located on perforated tape. I almost always have a couple gears in reserve. Fans have created an entire site with a collection of melodies.

The case is made of beech according to the customer's size, usually I make quite pocket versions, here the size of the box is 100x100x70. The blanks are sawn down, the photo shows how the box was assembled.

Tape clamps are used to tighten the corners.

The cover cut off with a margin is glued on top.

With a grinder I give the lid the shape of a chest. And only after that the box is cut into halves and the mechanism is inserted inside.

We try on the tape, it should go into the box "blindly", without opening the lid.

The hostess asked to put an engraving on the cover. No problem. It remains to clean the dust from engraving and cover everything with varnish.

I am a lazy craftsman and I also make ribbons for the box with a laser. Although the kit comes with a special hole punch for this.

We try on the tape and listen to the melody. Everything worked out!

The ribbon is completely placed in the box. It fits into small caskets with an accordion.

The hostess was satisfied, for some reason this is very important to me. :)

If you have a production or service that you want to tell our readers about, write to Aslan ( [email protected] ) and we will make the best report, which will be seen not only by readers of the community, but also by the site How it's done

We will talk about a device that is very simple to manufacture (even for a beginner amateur electronics engineer), but at the same time extremely interesting and useful - an electronic "music box". Also, as an example, I will show and tell about one of the possible incarnations and applications of this device - about the last gift made on its basis to my girlfriend.

History of creation

There will be many letters related to the matter rather indirectly, and if you want,

It all started a long time ago, a few years ago, when I wanted to give a girl some interesting, original and memorable birthday present. And of course with your own hands. There was very little time left before the holiday, two days, during which it was necessary to come up with something and, in fact, implement it. The day was spent thinking - hundreds of different options were spinning in my head, from all kinds of LED “flashing lights” - hearts, to various electro-mechanical crafts. But all this was not right: either too simple and beaten, or vice versa, quite complicated (and there is absolutely no time left!). Suddenly, a simple, but wonderful, as it turned out later, idea came to my mind: why not make a musical postcard? And not simple, but with a "chip", with an original melody. Moreover, we had “our own song”, under which we met and which evoked all sorts of pleasant romantic memories and experiences in us.
So the very first version of the “music box” was born, the progenitor, so to speak. Very simple, hastily assembled from a PIC12F675, a piezo speaker, a photodiode, a pair of resistors, a three-volt element 2016 and packed in a postcard drawn in Photoshop. As a result, this postcard was able, when opened (and the light hit the photodiode), to register the same melody with a rectangle. That's it, simple and uncomplicated.
But the idea turned out to be extremely successful, many times more than I expected. Subsequently, I made a few more of these simple postcards at the request of my friends, for their second halves. And in each case, such a gift evoked a lot of emotions both in the recipients themselves and in their parents, girlfriends and acquaintances :)
Quite a lot of time passed, everything started spinning, the project was forgotten. But it so happened that I again remembered the music box. This time it was supposed to be a gift for March 8th. At that time, I actively studied Atmel microcontrollers, in particular, played with ATtiny45, and decided to improve the music module for this. Moreover, this time there was a lot of time. That's where it all started.
Looking for various information on the Internet, I came across the site of Mr. Chan, widely known in narrow circles. More specifically, on one of his designs, a miniature synthesizer, just on my favorite MK :) Some time ago I almost finished a four-channel synthesizer on PIC18, but, alas, I destroyed the achievements in my heart (which I later regretted more than once). And Chan's design was quite self-sufficient and complete. It remained to add to it only the "trigger" and go!
I finished the code a little, and the trigger mechanism was ready. But then everything turned out to be somewhat less rosy. The main problem with the design was that it sounded too quiet. No matter how I tried, with the direct drive of the speaker from the MK pins, it turned out quietly and that's it! As a result, a strong-willed decision was made to add a power amplifier. The choice fell on the LM4900, which was then available in Terraelectronics. Again, I had to make some more changes to Mr. Chan's code in order for the synthesizer to work correctly with an external amplifier - to make the power saving leg control so that the amplifier does not eat the battery when idle and reconfigure the PWM to correctly output a signal from one pin. After these changes, the prototype worked just fine. Then I drew the first version of the board (in which, as it turned out later, a jamb crept in :) and assembled the music box in a human way. Further, everything is on the beaten path - a home-made postcard, installation of the module and donation-delivery.
Of course, this device was several heads higher than the previous ones - the very realistic sound of the "real" box and polyphony made themselves felt :) The gift, like in previous times, caused a sensation a long time ago. And I also collected about a dozen of these modules for my friends.

Now about the device itself

The current version of the module, the third in a row, contains a few more changes and one interesting innovation - light and music channel, to which you can connect, for example, an LED. But first things first.
Let's start with the diagram, it's very simple:


Her heart is a microcontroller ATtiny45/85. He is engaged, in fact, in the synthesis of music, manages the light and music channel and the energy saving of the amplifier. The second most important element is the audio power amplifier TPA301D. Connected to amplifier speaker, which is outside of the module. There is also a transistor BC847, which controls the light and music channel and several passive elements - resistors and capacitors. It all feeds on 2-3 alkaline elements (for example, AAA) located in the outer battery pack(the most common, Chinese). As you can see, the circuit is really elementary.
The principle of operation of the circuit
Most of the time the device is in "sleep mode". MK falls asleep at the command of the firmware immediately after turning it on, previously “putting to sleep” the amplifier, setting it on its leg SHUTDOWN high level (by connecting a weak leg lift "PB0" to the "+" power supply inside the MK). MK wakes up on interruption from the foot "PB2/INT0". Initially, the leg is also pulled up to the “+” power supply inside the MK and it must be shorted to the ground.
From the “PB1 / OC1A” leg of the MK, the audio PWM signal, in order to filter it from the carrier, passes through the simplest second-order RC filter ( R2-C3), which must be calculated (and in our case it can simply be “estimated”) for a cutoff frequency that is much lower (ten times) than the carrier frequency. And the filtered signal, through the blocking capacitor C2, is already fed to the input of the amplifier.
MK also controls an additional, light and music channel. For this, an npn transistor is used. Q1 in key mode, the base of which is connected to the leg of the MK PB4/OC1B through a current limiting resistor R1. There can also be a limiting resistor in the collector circuit ( R3) would not be redundant. The transistor is also driven by a PWM signal. Everything is done very simply - in the best traditions of "flashing" LEDs from the "arduino" :)
For nutrition, there is a decoupling tantalum ( C1), the simplest body kit of the amplifier, which acts as a decoupling ( C4), and adjusting the gain (volume), in general, is peeped in the datasheet for the amplifier. If necessary, the KU can be calculated quite accurately using the most common method for the op-amp, the ratio of the resistance of the input resistor R4 and feedback resistor R5, since it can be useful to adjust the volume for a particular speaker or design.
Printed circuit board
Simple to disgrace, drawn in DipTrace:


This is the third version, which takes into account all the previous shortcomings.
The board is designed for surface mounting and one-sided, which greatly simplifies the process of its home production. You can apply any method: laser ironing, photo method, or even draw tracks with a marker (for an amateur, of course).
All elements - 0805 (including "zero" jumpers), tantalum - A or B, a transistor in SOT23 and an MK with an amplifier in SO-8. All "peripheral" components - a battery pack, speaker, LEDs and a button (photoresistor, reed switch) are soldered to the corresponding "circles" on the board. That's all.
Software part

A bit about sound synthesis

You can read about the synthesis method used in the device in the original by Mr. Chan. You can also google "wavetable synthesis". If you do not speak the language, then in short, the memory of the MK stores a sound sample(a single sound), the so-called. "wave table", which in our simplest case is conditionally divided into two logical parts, which in general form "envelope" - attack, the beginning of each new sound, and "sustain", shutter speed, a fragment constantly looped throughout the sound of a note. Is there some more "decay", "tune-in", the part that sounds after the note is removed. We implemented it simply by gradually fading the sound of “sustain”. The MK has a timer that causes an interruption at a certain frequency, where, in accordance with the current position on the “envelope” and the pitch of the note, the desired value is selected from the sample memory. Moreover, in this way, you can synthesize several channels (that is, notes) at once at the same time, everything depends only on the processing power of the MK and the sampling frequency (sound quality).Then these values ​​​​are mixed and sent "to the output" (in our case, to the PWM control register).All this disgrace, as I mentioned above, is called “Wavetable synthesis” or “table-wave synthesis”.


The core of Mr. Chan's synthesis has remained virtually unchanged. I changed only the PWM output method a little, due to the rejection of the “direct drive” of the speaker with the MK. He added a “trigger”, energy saving control for the MK and amplifier, and also wrote a code for controlling the light and music channel, which works in this way: according to a special event from the score, the LED “lights” in the right places, and then smoothly “extinguishes” it. Well, I “ported” (strongly, of course, it is said) the code to the Studio, for convenience.
The code is written in AVR assembler and consists of several files: mbox.asm- in fact, the program itself; "notes_pitch.inc"- an indication of the correspondence of the mnemonic names of the notes used in the score, the coefficients of increment of the pointer position in the sample (that is, as a result, the pitch); wavetable.inc- sample data ("table") and decay curve "decay"; A score.inc, as you probably guessed by the name, contains the score of the piece being performed, the “notes”.
Initially, in "wavetable.inc" Chan himself "hammered" the sound of the box. But if necessary and desired, it can be changed to any other using an auxiliary script wav2asm.pl or just by hand.
The situation was more complicated with the score. Originally it was supposed to be written by hand, which will undoubtedly bring a lot of pleasure to human masochists, especially if the score is not at all simple.
For a person who is going to use his score and, presumably, for this reason at least somewhat familiar with music and musical notation, it would be easier to draw a score in any available music editor and somehow use it. For this I wrote a special converter program, which accepts a midi file of format 0 as an input, and gives the finished file "score.inc" as an "output". It can also independently arrange LED ignition events for all notes found in the first channel, that is, if the melody is initially logically separated from the accompaniment and moved to the first channel of the MIDI file, then we will get a score that will light the LED in time with the melody, if we want and put a daw. In fact, this is perhaps one of the most beautiful options for the additional channel.
The program can also transpose the resulting score by one or two octaves up/down, which in certain cases can greatly facilitate the work of writing the score.
The interface of the program looks simple, understandable and unpretentious, and the Delphi sources are included in the kit:

By the way, as I was prompted at the time (for some reason I didn’t think about it at all), there are a lot of resources on the Internet where you can get ready-made midi with the desired melodies. They will only need to be slightly modified for use in my converter. And some may not even need to be modified.

What else might be needed?
Let's say you bought / got all the necessary components, made a board in one way or another, or, alternatively, simply soldered everything by surface mounting. What else will be needed? You will need a programmer. If you already have or are dealing with an AVR, then you most likely already have it. And so, suitable, for example, "USBasp" in hundreds of incarnations or any other. There is nothing supernatural here. The archive with everything-everything has an already compiled binary, which can be immediately uploaded to the controller and used if there are no intentions to edit and rebuild something.

Application

And now, as promised, I will tell and show one of the hundreds of possible applications of the module, the Kawasaki musical rose.
Rose Kawasaki, one of the masterpieces of origami, is generally a separate big topic, which you can fully familiarize yourself with on the Internet.
Structurally, the thing itself is made of two parts:
First, rose, folded from a colored sheet of paper and glued to a twisted stalk with leaves (also folded from colored paper). A thick copper wire runs inside the stem (for strength) and a small neodymium magnet is hidden at the very bottom.
Second part, vase, cut and glued from thick white cardboard. Inside it is installed the module itself, a speaker (glued to a resonating volume filled with cotton wool), super-bright white wide-angle LEDs, matted with fine sandpaper and a battery pack fixed at the bottom of the vase for easy access to batteries. And, of course, the reed switch is a “trigger mechanism” that works in tandem with a magnet in the stem. It is installed in such a way that the module is activated when the rose is taken out of the vase.
Schematically, it looks like this:

Here are a couple photos of the prototype:

And video work. The composition “Tenderness” plays on the video, which I arranged for the box, and which is included in the archive as a source (typed in Sibelius) and a midi, as well as a finished generated score:

As usual, my eternal problem with normal sound in the video makes itself felt. A thousand apologies. If you are interested in listening to how the construction sounds in normal quality, you can download the empetrishka from here.
This is just one of the possible applications of the design. How you use your module will depend on your imagination ;)
It only remains for me to wish you success in this difficult creative endeavor.
Give joy to your loved ones!

Disclaimer and thanks :)

P.S. This is my first post here, so please don't kick too hard if I'm wrong about something or somehow.
P.P.S. I have already published this material partially and in a fragmented form in my LiveJournal, more for myself, to note some points and leave a reminder, but since the device turned out to be very interesting and successful, and there are already several modifications of this device in almost a couple of dozen incarnations with more than fulfilled (and continue to fulfill) their mission - they delight the ears and eyes of girls - then I decided to tell you about it.
P.P.P.S. Also, for a story about the following device here, on Habré, a friend encouraged me for a long time, and now, finally, I gathered my strength, knocked out the material and decided to write this post, for which many thanks to Long!

I came across some interesting things from AliExpress on the lifehacker website. Namely, the mechanism for the music box. And without thinking twice, I ordered this gadget for myself :)

I was very interested in this position, since since childhood I liked to watch in films how the heroes play a melody from caskets. I like the tone of such melodies, the rhythm and stuff like that.
The idea itself is extremely simple. You can make any box with your own hands and insert a mechanism there, you get an original little thing. But since my hands are growing out of the wrong place, I just love to listen to this melody without external embellishments. Plays here by the way Castle in the Sky Theme Song. I don’t know where and who the author is, but I like it :)

The parcel went for about a month. Tracking stopped after crossing the border. Apparently the Chinese saved on a normal track code. Anyway.


Packed in a regular bag and thin foam. No bubbles :(


They also promised 4 screws, and there were 2 current in the package, but these are minor quibbles.
Dimensions 5 cm by 4.5 by 2 Everything is connected on one frame.


Sounds are produced by plates of different lengths that are caught by a small drum with protrusions in certain places. The Chinese have such drums for different songs and it would be interesting to rearrange them depending on the mood.


Everything is set in motion by a spring that is turned on with a special key. There is nothing more than nanotechnological here :) What would the melody play more evenly, there is a braking roller.




If you hold the mechanism in your hand, the sound is very quiet, well, everything is perfectly audible on the table.

The seller promises 500 repetitions of playback, in the future it will be seen how this mechanism behaves.

I plan to buy +18 Add to favorites Liked the review +40 +59