The idea of the Jukebox
Children love surprises, e.g. a "miracle box" that plays a melody as if by magic. I tried that - the success was sensational. The Jukebox from the Wunderkiste knows many melodies to sing and bounce children. The effort is worth it.
But also regardless of the "miracle box", it is sometimes desired that a player automatically starts when the power supply is switched on. For example for a warning, an important error message or another announcement. Of course, he has a function to play the first jingle. The problem is: If you switch on the DFPlayer, it needs about 2s to be ready. Only then can you start an MP3 file. This process has to be automated.
The following components are required:
1 |
|
1 |
|
2 |
|
1 |
|
7 |
Resistance from resistance range |
2 |
Condensators from ElkosorteMent |
1 |
10 NF out Ceramic capacitors range |
1 |
|
2 |
CD4093 - Electronic specialist trade |
1 |
NE555 (Amazon) |
1 |
NPN transistor 2N2222 (Amazon) |
The DFPlayer
The module is described in detail in the AZ documentation, and the functions are also shown in detail in order to control a DFPlayer using a microcontroller. E.g. in 6-part contribution to the TDMM this is explained exactly. For the application described, we do not use a microcontroller, but the adkey functionality of the DFPlayer with some hardware around it.
For this purpose, two resistors are connected to the adkey1 connection, in our case 15 kΩ and 24 kΩ. At the other end of each resistance there is a button that establishes a connection to mass (GND). So entsteht durch einen internen Widerstand im DFPlayer ein Spannungsteiler. The DFPlayer measures the resulting voltage, recognizes which resistance has been switched to mass and carries out the desired function.
With this elegant circuit you can map 10 functions over 10 different resistors and yet only needs one pin on the player. This saves a "cable cheeky" on 10 digital pins. The player remains compact and yet offers a wealth of functions, of which we only need two this time.
We will use a button to play the next jingle or increase the volume (press longer). SW1 reduces the volume or plays the previous jingle.
The technical challenge
The actual challenge lies in the time after switching on the power supply:
• Device is switched on; The player is ready after about 2s.
• Only then is an impulse of approx. 200 - 300 ms used, which briefly draws the adkey1 connection via the 24 kΩ resistance. This impulse simulates the manual key pressure on SW2.
You could program a simple microcontroller without much effort. That will of course work. In our case, I link the technical solution with four small chapters of analog and digital circuit technology. Namely:
• The RC member as a timer; How is it calculated, how does it work?
• A Schmitt trigger for signal formation
• The function of the XNOR switching circuit as a digital comparier
• NE555 - The classic work horse for many tilting circuits provides the 200ms switching pulse
Don't worry, it's no rocket science! I think it is a little fun to immerse yourself in the basics of electronics again.
Let's take a look at the circuit for this:

illustration 1: Jukebox circuit
The RC member as a timer; How is it calculated, how does it work?
On the left side of the circuit diagram we see the power supply +5V as a circular symbol with a "="
in the middle. The time-determining RC member is formed from resistance R1 (22 kΩ) and the capacitor C1 (100 UF). This RC member provides the switch-on delay. Let's take a look at the circuit simulation, which shows us the output voltage V (out) on C1 as a function of the time (x-axis) for the duration of 6S:

illustration 2: Voltage course V (out) of an RC member
The operating voltage is created at time 0. At this point, the voltage on C1 at 0V. Now the capacitor C1 is charged via resistance R1 and reaches a voltage of 3V after 2S. After 6S (far right) it only arrived at approx. 4.7V!
The time constant of an RC member is calculated in this way:
t = r x C [S]
The resistance R is given in Ω, the capacity C in F (Farad). This is a bit unwieldy because we use a capacitor of 100 µF here, for example. 1 µF is a millionth of Farad. So we calculate:
t = 22000 Ω x 0.000 1 F
T = 2.2 s
In 2.2s, the capacitor has charged from 0V to 3V. That is what the term "time constant" says. It then arrived at around 60% of the input voltage. This is exactly what the circuit simulation shows.
When is it really charged to 5V? The theoretical physicist replies: never!
The pragmatic electronics technician cannot do anything with it. He uses the proven rule:
A capacitor is fully charged at 5 x T - the five -time time constant. In our case about 11s.
How do we use the RC member?
Our requirement was: We want the Jukebox to start after about 2s. Until then, the DFPlayer needs some time to get into the "ready state". Then we need an impulse of approx. 200 - 300 ms, which simulates a push of a button and thus triggers an ADKEY1 function.
We are now building a circuit that wait until the capacitor is charged to 3V after 2s and then switches. We could also measure the tension via the analogue input of a microcontroller, but we want to use our basic electronics knowledge here and remain with classical technology.
We use a so-called "discriminator circuit", a Schmitt trigger who takes over the switching.
The Schmitt trigger CD4093
This CMOS chip has proven itself as a work horse. As a NAND gate with a switching threshold, it compares two tensions and delivers a digital output signal if the voltage is larger or equal to the comparison voltage, which we set with the potentiometer RV1. The PIN 1 input is connected to RV1, the other PIN 2 input with the capacitor C1.
The 4093 "looks at the capacitor when charging". As soon as the comparison voltage has arrived at the potentiometer at 3V, it jumps Ausgang A to "logical zero = 0V", because we are dealing with an NAND gate. We only need to set the Poti RV1 so that this happens after approx. 2S.
The easiest way is to set the Poti RV1 with a DVM (or the TDMM) to 3V.
To do this, I made a few attempts and found that the 100 µF electrolyte capacitor from the AZ range box is quite high quality. If you make several attempts to determine the optimal time, then you have to discharge the capacitor again and again between the tests via a resistance of e.g. 100 Ω. Please do not short -circuit! The capacitor stores the cargo so well that you can never start at 0V. And then the whole setting is wrong.
Now we have managed to trigger a switching process at the right point on the way of voltage V (out). What's next? We want to map the following pulse scheme:

illustration 3: Signal processes on the Schmitt trigger U1
The diagram shows three digital signals on the chip U1:
• The Exit A, referred to here as the "U1a", the Schmitt trigger, which has just been discussed. It changes to Low (0V) after about 2s from High (+5V).
• The output U1b of another Schmitt trigger who is waiting up to C1
• The Output B, here referred to as "U1C", which inverts the output signal of U1B. He makes "high" "low" and vice versa. We immediately understand what the inverter is necessary for.
We recognize the simple logic: The Schmitt trigger U1a switches to low after 2s. The second Schmitt trigger U1B compares the 5V operating voltage (PIN 6) with the voltage of C1 (PIN 5). He waits for the capacitor to be fully charged. Since a Schmitt trigger deliberately brings a hysteresis, ie a "scope" within which it switches, he tilts the exit earlier than one would expect, to low. You can see in the simulation that the exponential charging curve of C1 is always flatter when the tension increases. The voltage course follows the natural logarithm. This property of the RC member and the hysteresis of the 4093 deliver low to output B about 50ms after the first switching process to U1A.
How do we generate an impulse to start our DFPlayer?
If you compare the red signal course to U1A and the U1C, find that the two signals are high in the first 2s. After 2S, the flank from U1A falls on low, while U1C still remains high. That changes when U1C 50ms later gets to its switching threshold.
The signals are therefore unequal for a period of approx. 50ms (dashed green line; the ∆t is to clarify not marked in terms of scale!). Otherwise, both signals are the same: either high or low. With these signals we control a circuit that can differentiate between the same and unequal signals Xnor-Gatter, a digital comparier.
The function of the XNOR switching circuit as a digital comparier
XNOR gate receive digital signals on their inputs A and B and provide an answer at the output according to this truth table:

illustration 4: Truth table of an XNOR gate
We don't use Xnor chip for this, although that would be possible. We take another CD 4093 (I paid 35 cents for an IC) and build an XNOR gate from it. The circuit for this is generally known, which is why I don't want to explain it here again. You can see the circuit block with the U2/U3 circuit in our switching scheme in illustration 1 Under the heading "Impulse filter - Xnor -Gatter from Nands". The 4093 contains all four NAND gates, which are designated here with U2/U3.
The XNOR delivers an impulse at the PIN4 / U3B output that takes as long as the two signals (see above) are unequal. When building my sample, these are 50ms.
This impulse is too short to start the DFPlayer. The player is set up for the operation by a person and expects a button pressure of ≥ 200 ms. So we have to extend this impulse. To do this, we use an RC member again that is connected to a classic timer chip this time, the NE555.
NE555 - The classic work horse for many tilting circuits
There are entire books and numerous applications for this classic that came onto the market in 1972. It is probably the chip sold worldwide: Wikipedia/NE555
The time-determining RC member form R2 (22 kΩ) and C3 (10 µf). The time constant is calculated again directly from R and C, but multiplied by a factor of LN (3) (LN (3) ~ 1.1):
T = R x C x 1.1 [S]
With our dimensioning, it results:
T = 22000 Ω x 0.000 01 f x 1.1
T = 240 ms
The NE555 is switched as a monoflop. This is how a circuit is called a circuit that gets a starting impulse, ie "toast" and responds to it with a precisely defined impulse. In our case, the starting impulse is about 50ms long, the answer of the NE555 is an impulse of 240ms.
Now we have arrived at the destination with the signal preparation. From charge of a capacitor we have derived a time delayed signal that can start our DFPlayer.
Tax transistor 2N2222 as the last switching level
The high output signal of the NE555 is not suitable for heading for the Adkey1 input. To do this, the 24kΩ resistance must be "pulled to mass", i.e. on low. We use an NPN transistor 2N2222. Its base is controlled with the high signal of the NE555 via the 4.7K resistance R3. The CE route of the 2N2222 becomes leading, the 24K resistance to ADKEY1 is almost on mass for 240ms. The DFPlayer starts reliably with this circuit.
Good to know
If the circuit was switched off for a few minutes, the capacitor C1 had enough time to discharge. If you want to restart the circuit 5 times a minute (children have such ideas), then he cannot discharge sufficiently. The player does not start.
A resistance of 470 kΩ parallel to the capacitor helps. In this case, the setting of RV1 may have to be corrected somewhat.
Switching and operation of the DFPlayer
In the lower, left part, the circuit diagram shows in illustration 1 the DFPlayer with its rather clear circuit. The player brings an integrated amplifier to which a loudspeaker with 8 Ω impedance and an output ≤ 3W can be connected directly.
In addition to the power supply, only the two resistors R4 (15 kΩ) and R5 (24 kΩ) are needed, which can be connected to mass using two buttons. We form R4 from a 10 kΩ and a 4.7 kΩ resistance that are switched into series. For R5 we switch a 22 kΩ and a 2.2 kΩ resistance in a row.
Don't forget: the connection from the collector of the switching transistor T1 to SW 2.
This means that the small device is fully built and functional. It has an switch that is set up in such a way that it turns on when the "miracle box" is opened and two buttons for operation:
• Buttons SW2 is pressed briefly, To play the next jingle (press briefly) or increase the volume (Press longer).
• Taster SW1 reduces the volume (press short) or play the previous jingle (press longer).
Note: I have no idea whether this is only the case with my three DFPlayers, but in all data sheets and also in the wiki of the manufacturer Dfrobot the functions are given the other way around. Please test!
Where does the music come from?
If you want to play music for children, I can pass on a practical tip of the FOCUS magazine, which deals with this topic:
Download children's songs for free
Otherwise also offers Children's songs on Pixabay An area with free children's song downloads and you will certainly find more sources online.
How does the music get on the SD card?
In fact, this process is not completely trivial.
• The SD card has FAT16 format. FAT32 obviously works too.
• MP3 files are played in the order in which they were installed. All possible names do not change that.
• Fillen names are 4-digit numbers that can follow a text. For example: 0004_alle_meine-entchen.mp3
• The MP3 files are located in a folder called Musik.mp3

illustration 5: Content of the Musik.mp3 folder
I will be happy to provide you with my MP3 files as part of this article. This saves you some search work and annoying problems with the file system.
If you would like to pack more songs in the folder, please select the next number and put the file in the folder. Problems can occur for MAC users, because some Mac created - without being asked or he shows it - an additional file in the way: " ._0001.mp3 "Or similar. This file looks like an MP3 for the DFPlayer, but does not contain music and disturbs the process. It is not generated by every Mac OS X version, but from older systems. You get rid of this file by opening the terminal program with admin rights and entering the following instruction:
dot_clean /volumes /
Power supply
For my purposes, I connected four AA batteries to a 6V bundle. The device is supplied with a stepdown converter LM2596S, which is set to 5V.
And now I wish you and especially your children and their friends a lot of fun with "music on the miracle box"
Your Michael Klein