So... you've apparently abandoned the simple sketch we were discussiing, which you could not get to work. Presumably you did not try the suggestions I made in post #31?
And you now want to discuss a different and slightly more complex sketch, yes? Which is also not working?
Oh, I also meant to ask if you have successfully played files with this DFR module previously?
Apologies for the longer script, I was interested to see if the print details section maybe gave me more details on what was happening. I have moved everything onto a breadboard , gone back to the original library and no sound still BUT thanks to you and @runaway_pancake and @Delta_G , I at least have the module initialising now , which I did not before.
THis is a brand new module I have not used before , so is the speaker.
I have just connected a new speaker and a new out the packet DFPlayer , exact same results
@runaway_pancake may I ask for a picture of your SD card ? Because we know that:
1)The code works fine from your test and @Terrypin also testing your code
2) I am using a different DFmini player now and a different speaker
So it must be the SD card ?
Sorry - I don't have it with me now; I'm about to start on at work. It's a 2GB, though. (Maybe that's not important.)
It's 'Class 4'.
I see that you have a much longer track now as 0001.mp3
N.B. ─ The file system for it is weird. Regardless the name, number-wise, it "sees" everything by date/time it was placed on the SD. (So, it will play '0002' as play(1) because it's older). To change everything, you have to pull everything off it and then back on, one at a time, in the order desired (renamed to match).
Clear as mud?
If you leave everything as it is --
#include "DFRobotDFPlayerMini.h" // Do Not Forget or Omit This
DFRobotDFPlayerMini myDFPlayer;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
delay(2500);
myDFPlayer.begin(Serial1, true);
Serial.println(myDFPlayer.begin(Serial1));
if(!myDFPlayer.begin(Serial1))
{
Serial.println("Problem");
while (true);
}
if(myDFPlayer.begin(Serial1))
{
Serial.println("Good");
}
}
void loop ()
{
myDFPlayer.play(2); // a brief track, but may drive you nuts
delay(20000);
}
should play that longer track for 20 seconds - and then start over again.
yep, that is clear as mud. Thank you for letting me know. and thank you so much for your time. I am going to keep fiddling, please post anything else that comes to you .
And did you format the mSD and reload the file(s) as I suggested?
BTW, what laptop or PC are you using? If it's a mac then it's even more important to format the mSD, as spurious hidden files are sometimes placed on it as well as your audio.
I assume you don't have another speaker to add as I suggested, to eliminate that possible but unlikley cause?
Bottom line: with that sketch (with no lines missing) and a good power supply you should hear your file 0001.mp3 play. If not, please tell us exactly what you do see and hear.
I have formatted and recopied the files.
I am on an HP running Windows, no Mac, sadly .
I have tested with a different speaker and a different DFRmini ( I have three of each) I did find a 22 ohm resistor which I will try in series with the speaker next
I noticed a few minor changes in your latest code. It might help if you study my version, particularly the comments about volume setting.
And remember that if there is a supply issue (whether due to your 4 ohm speaker or some other cause), then setting a max volume of 30 increases the risk.
// My edit: essentially replacing 'Serial1' with 'mySoftwareSerial'
// See post https://forum.arduino.cc/t/using-dfrobot-dfmini-player-with-arduino-mega/1146443/20
#include "DFRobotDFPlayerMini.h"
#include "SoftwareSerial.h" // Added
SoftwareSerial mySoftwareSerial(8, 9); // For my UNO
DFRobotDFPlayerMini myDFPlayer;
void setup()
{
Serial.begin(11500); // Edited to my preference
// Serial1.begin(9600); // Replaced with
mySoftwareSerial.begin(9600);
// delay(2500); // Never found it needed
// myDFPlayer.begin(Serial1, true); // Replaced with
myDFPlayer.begin(mySoftwareSerial, true);
// Serial.println(myDFPlayer.begin(Serial1)); // Replaced with
Serial.println(myDFPlayer.begin(mySoftwareSerial));
// if (!myDFPlayer.begin(Serial1)) // Replaced with
if (!myDFPlayer.begin(mySoftwareSerial))
{
Serial.println("Problem");
while (true);
}
// if (myDFPlayer.begin(Serial1)) // Replaced with
if (myDFPlayer.begin(mySoftwareSerial, false))
{
Serial.println("Good");
}
myDFPlayer.volume(20); // Otherwise defaults to max 30
delay(500); // Volume fails if delay less than about 100 ms
// Note: no point setting volume repeatedly in loop()
myDFPlayer.play(1); // Play any file here
// Could then leave loop() empty while testing.
delay(5000);
}
void loop ()
{
myDFPlayer.next(); // Or leave loop() empty while testinmg
delay(2000);
}
It turned out to be the SD Card, it is super weird, it plays all the tracks on my computer without any issues but just does not seem to like the mp3player - I purchased a new memory card and we have lift off. Thank you all so so so much ! @runaway_pancake the blarsted thing is go ! I might get this PhD yet ( in Computer Science not electronics). THank you so much for this forum and the help. I might be back as I build the last pieces of my tangible user interface. THANK YOU !!!!!!!