DF Player Pro+Arduino. Play specific sounds one after the other
Francisco.Lopez-Linares 2024-03-20 08:41:57 1060 Views6 Replies Hello:
I bought a DFPLayer pro to be able to play wav files from its own memory, while arduino does “another things”.
Sadly I have found that though there is a function call “isplaying” to know when a sound has end it, while this function is been run, it “stalls” arduino execution, so at the end is more or less the same as inserting a delay in the code…, so I think this function is useless for my case.
I need to develope a function to send mini player something like this:
play_sounds("one.wav", “two.wav”, "four.wav");
So DFplayer takes care of playing those sounds (that are in it's memory), while Arduino takes care of other stuff…
Anyone know if any function of this type has been develop or any special function I can use to get to this goal?
Thanks for your time.
That's a classic challenge with the DFPlayer when you need non-blocking playback. The issue is that isplaying() polls the module, and while it checks the status, your Arduino code essentially waits at that line. For true parallel operation, you need a state-based approach.
Instead of relying on a blocking check, you can set up a system where the Arduino sends the command to play "one.wav" and then immediately returns to its main loop. You would then use a timer (like the millis() function) to check the duration of the sound. When the timer expires, you send the command for the next file ("two.wav") in your sequence. This lets your Arduino manage other tasks seamlessly between sounds, which is exactly what you need for a function like play_sounds().
For your project, searching for "Arduino non-blocking DFPlayer tutorial" will provide you with specific code examples to build your function.
Nicholas.Morgan Not thanks to the help in this forum, I have conclude that DFplayer needs arduino to play the sounds, so for me is not of very much interest. I have used with much more sucess other reproduction modules wich play the sounds without “halting” arduino.
Francisco.Lopez-Linares Success! It could be one of the most informative blogs we've come across on the subject. Great information! I am also a specialist in this field, so I understand your efforts very well. Thank you so much for your help. play slope
henry.katy Is this forum officaly attend it?
Should I expect an answer from DFROBOT?
Francisco.Lopez-Linares I have just realized that “DF1201S.playSpecFile”, also blocks de execition of arduino….., so with the actualk state of the firmare, I'm afraid the devices is useless for me :-(..
Francisco.Lopez-Linares Take into account that In the memory there are 100 sounds, and an specific moment I need to play only those three sounds.., so the function that plays all the sounds on the folder can't be used.
Francisco.Lopez-Linares 

