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.


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
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.


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.


Here it is…

#include <DFPlayerMini_Fast.h>

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

DFPlayerMini_Fast myMP3;

void setup()

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

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



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.


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