DFPlayer mini Programe
Hi Team members,
Good day! ![]()
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include <Button.h>
#define BTNPIN A1 // Push button
Button button2(A2); // Connect your button between pin A2 and GND
Button button3(A0); // Connect your button between pin A0 and GND
Button button4(A3); // Connect your button between pin A3 and GND
SoftwareSerial mySoftwareSerial(6, 7); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
Button playPauseButton(BTNPIN);
boolean isPlaying = false;
void setup() {
mySoftwareSerial.begin(9600);
Serial.begin(9600);
delay(1000);
Serial.println();
Serial.println("DFPlayer Mini Demo");
Serial.println("Initializing DFPlayer...");
if (!myDFPlayer.begin(mySoftwareSerial)) {
Serial.println("Unable to begin:");
Serial.println("1.Please recheck the connection!");
Serial.println("2.Please insert the SD card!");
while (true)
;
}
Serial.println(F("DFPlayer Mini online."));
playPauseButton.begin();
button2.begin();
button3.begin();
button4.begin();
//----Set volume----
myDFPlayer.volume(30); //Set volume value (0~30).
//myDFPlayer.volumeUp(); //Volume Up
//myDFPlayer.volumeDown(); //Volume Down
//----Set different EQ----
myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
// myDFPlayer.EQ(DFPLAYER_EQ_POP);
// myDFPlayer.EQ(DFPLAYER_EQ_ROCK);
// myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
// myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
// myDFPlayer.EQ(DFPLAYER_EQ_BASS);
myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);
//myDFPlayer.play(3); //Play the first song
myDFPlayer.loopFolder(2);
isPlaying = true;
Serial.println("Playing..");
}
void loop() {
if (playPauseButton.pressed()) {
delay(100);
//if (myDFPlayer.{
//mp3.pause();
myDFPlayer.pause(); //pause the mp3
delay(1000);
Serial.println("Song is paused");
}
if (button2.pressed()) {
delay(100);
myDFPlayer.next(); //Play next mp3
delay(1000);
Serial.println("Next Song is being played");
}
if (button3.pressed()) {
delay(100);
myDFPlayer.previous(); //Play previous mp3
delay(1000);
Serial.println("Prev Song is being played");
}
if (button4.pressed()) {
delay(100);
myDFPlayer.volumeDown(); //Volume Down
Serial.println("Volume reduced");
}
}
i'm using the below command to loop the songs (repeat the songs) from folder number 2
myDFPlayer.loopFolder(2);

also if using navigation for next or previous songs, after all the tracks from folder are completed, it starts playing folder 3 for NEXT and folder 1 for PREV.
is there a way, to stop it.
yes, if i'm not operating any button for NEXT or PREV, it loops all the tracks in folder 2.

also, if i pause it and resumes, will it continue to “loop folder”?

please suggest, if something i'm missing here.
Thanks in advance.
Cheers…
PD