The player only starts working when I press the 'Next' button. I want it to start playing straight after I turn it on. I included player.play(1); in the setup, but it won't work. Also I wanted to set the initial volume, but that doesn't work either. (player.volume(10);)
I have a folder called '01' and two files: 001.mp3 and 002.mp3 in that folder.
Since the Next button works, the DFplayer is up and running. The Arduino just can't communicate with it. The problem is likely in your wiring. Please show us a schematic. A clearly drawn pen and paper one is perfectly acceptable.
I'm using the arrangement below, but I swapped the 10k resistor in the RX line with a 1k one as the specs shows for the DFplayer. It didn't work with the 10k one. Also I didn't connect anything to the pin where a 'pause' LED supposed to be.
Oh, you're not using the Next button on the DFplayer? So the Arduino can communicate with the DFplayer, just not at startup. Try adding a delay(2000); between player.begin(...) and player.volume(...). It may be that the DFplayer simply takes a bit longer to start up than the Arduino.
It looks like my file structure was the issue. I placed those files in the root folder, and it started working. Adding delay was a good idea too, but luckily it's not necessary.
Now the only issue is the pause button, as it's very fiddly and hard to operate, but I guess it's something to do with the timings.
the pause button is the easiest part:
define this in the beginning: bool Pause = false;
and use that in the loop:
// pause/play Button
if (button_b.released()) {
if (busyState == LOW) {
Pause = true;
myDFPlayer.pause(); // pause if playing
digitalWrite(LEDb, HIGH);
}
else {
Pause = false;
myDFPlayer.start(); // start if not playing
digitalWrite(LEDb, LOW);
}
}
Attention: I use the busy pin of the player to check if playing or not. You can do that with a variable as well. Just reading the status of the player is not very reliable.