DFPlayer mini mp3 player Random track

Hi

Im working on a project with the dfplayer mini mp3 player and i want it to play a random track at a random time between 5 and 10 minutes.
ive only gotten the mp3 player to play the next track and now im stuck.
Is there anyone who has experience working with that mp3 moduel and know an easy way to make it play a random track with the press of a botten?

Thanks!

I have not used such a module. However, here

has an explanation 'mp3_play (74); means playing audio file 0074.mp3 '. Try using it with 'random()'

, as well as for times between songs.

Thanks for the replay!

I have now figured out the real problem, its regarding the .play() funktion.
It seems to not work at all, ive looked around for a bit and tryed different codes but nothing works. Im begining to think something is wrong with the moduel i have :frowning:

If you or anyone have any sugestions plese let me know

PS. im using the DFRobotDFPlayerMini.h library

I don't know what all you've done so far. And you failed to "post your code".
I've seen lots of problems with these things lately. I had a few stashed for over a year, pulled one out and it worked for me first time out.

Reformat the SD and put 2 short MP3s on it, name them 001.mp3 and 002.mp3, copying them to the SD one at a time.
And then get the player going right without other complications,

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 2; // Connects to module's RX 
static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX 

SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
DFRobotDFPlayerMini player;

void setup() 
{
  Serial.begin(19200);
  softwareSerial.begin(9600);
  if (player.begin(softwareSerial)) 
  {
    Serial.println("OK");
    player.volume(22); //30 is very loud it seems
  } 
  else 
  {
    Serial.println("Connecting to DFPlayer Mini failed!");
  }

  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
}

void loop() 
{
  Serial.println("Playing #1");
  player.play(1);
  Serial.println("Pause . . .");
  delay(2000);
}

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