DFplayer Mini Project Help

Hi All.

I have looked through lots of DFplayer projects and cant seem to find one which matches what I want to do.

I want to use a Nano and a DFPlayer Mini to make a box which either plays random tracks when it is switched on or when a button is pressed after it is switched on.

I will need it to play ALL tracks on the SD card in Random/Shuffle mode and allow repeat tracks.

Any advice please.

Thanks

What have you tried? There are several DFMini libraries and they all come with examples of playing tracks. Look at the DF_Mini_Fast (or something like that) in the library manager

Thanks for the reply.

Ok so ive got this setup in the default wiring so it will just play when its fired up.
To help test the random function ive placed 30 x mp3 files on the card and they are spoken number files 1 to 30.
With just the random command added I get this which isnt very random for example
2,10,2,11,10,13,10,6,13
Basically 10 comes up every other number.

I have tried various libs and it does the same pretty much.

Im very new to arduino coding but getting my head round it now so just need a few pointers.
I was thinking maybe run the random command for first track then run it again for the second etc
as the first track is always different.
Any advice would be great.

Thanks

If you post your code we could see HOW you are using random(). Maybe you just need to include randomSeed() so that each run produces a different sequence.

But you also need to realise that even in a genuinely random sequence 10 may come up quite often. It’s random, which means you never know when things will turn up.

Steve

Here it is…

#include <DFPlayerMini_Fast.h>

#if !defined(UBRR1H)
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
#endif

DFPlayerMini_Fast myMP3;

void setup()
{
Serial.begin(115200);

#if !defined(UBRR1H)
mySerial.begin(9600);
myMP3.begin(mySerial, true);
#else
Serial1.begin(9600);
myMP3.begin(Serial1, true);
#endif

Serial.println(“Setting volume to max”);
myMP3.volume(30);

Serial.println(“Random”);
myMP3.randomAll();

}

void loop()
{
//do nothing
}

So that’s all down to whatever the YX5200-24SS chip on the DFPlayer is doing with it’s randomAll command. I don’t know any way to control the internal workings of that chip.

If you want it to do something different perhaps you could loop selecting the file number yourself with the Arduino random() command and play single files yourself.

Steve

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.