Hello. This is my first time working with this DFPlayer and I dont really know what I do.
I've connected all the pins and the player is initialized/found but i cant really controll it
The LED on the player is not even on.
This is the code I used:
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void setup() {
Serial.begin(9600);
mySoftwareSerial.begin(9600);
Serial.println("Initializing DFPlayer...");
if (!myDFPlayer.begin(mySoftwareSerial)) {
Serial.println("ERROR: Could not detect DFPlayer.");
while (true); // Stop execution
}
Serial.println("DFPlayer initialized successfully.");
myDFPlayer.volume(20); // Set volume
delay(500); // Wait a bit for volume to apply
int vol = myDFPlayer.readVolume();
Serial.print("Volume set to: ");
Serial.println(vol);
myDFPlayer.play(1); // Play track 0001.mp3
Serial.println("Playing track 1...");
delay(3000); // Give some time to start playing
}
void loop() {
int state = myDFPlayer.readState();
if (state == 0) {
Serial.println("Stopped.");
} else if (state == 1) {
Serial.println("Playing...");
} else if (state == 2) {
Serial.println("Paused.");
} else {
Serial.print("Unknown state: ");
Serial.println(state);
}
delay(1000); // Check status every second
}
I need to mention that all the files are mp3 and are named accordingly (001.mp3,002.mp3,etc)
Also something weird happens: When I try to use .play(1) it doesn't work but with playFolder(1,1) it just stops after a bit
