Hello, I am trying to use a DFplayer to make sounds synchronized with lights and I have used a DFplayer before. I'm just using a simple program to figure everything out but here is the code:
#include "Arduino.h"
#include "DFRobotDFPlayerMini.h"
#include "SoftwareSerial.h"
int button = 6;
boolean isPlaying = false;
DFRobotDFPlayerMini myDFPlayer;
SoftwareSerial mySerial(10, 11);
void setup()
{
pinMode(button, INPUT);
mySerial.begin (9600);
Serial.begin (115200);
if (!myDFPlayer.begin(mySerial)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("Unable to begin:"));
while(true);
}
Serial.println(F("DFPlayer Mini online."));
Serial.println("start");
myDFPlayer.volume(10);
Serial.println("done");
}
void loop()
{
if (digitalRead(button) == HIGH)
{
Serial.println("test");
if(isPlaying)
{
myDFPlayer.pause();
isPlaying = false;
}else
{
myDFPlayer.play(1);
isPlaying = true;
}
}
}
I have the DFPlayer with vcc to 5v, RX to pin 11, TX to pin 10, Speaker + to positive side of speaker ground to ground, and speaker - to negative side of speaker.
My problem is strange: If i have the speaker connected and start the arduino the DFplayer makes a loud popping noise and I get the message that it is unable to start. But with the speaker disconnected I can start the arduino, connect the speaker, and then it works as it should.
So in short I can only get it to play sounds if i connect the speaker after it is turned on. My only theory is maybe the DFplayer does something with the speaker when it is first powered? but I couldn't find any other posts with a problem like this. Any ideas as to what is causing this issue?

