Categories
Uncategorized

DF1201S MP3 PlayerPro & Arduino

One of my uses for this blog to is to record useful information that I (and others) might need later.

I’ve used the DfRobot Player Pro a couple of times in “stand alone” mode. It’s a great audio player: small, cheap, and easy to use. It also has a serial interface so it can be controlled by an arduino or microcontroller. DF Robot provides the DFRobot_DS1201S library to make this easier. However, all the examples I see online are using the playFileNum(num) command that takes an index of a file (MP3) to be played. The problem with this is that the file index depends on the order in which the file file was stored to the Player Pro’s Flash memory.

There is also a playSpecFile(String) method that takes a filename, which you’d expect is much easier and would be more popular. However, when I tried using it, it always played the same song. OK, time to debug. There is also a method in their library to retrieve the name of the currently playing file. However, when I use code like this:

// Play file
DF1201S.playSpecFile("one.mp3");
// Print name of file that's playing
Serial.println(DF1201S.getFileName());
DF1201S.playSpecFile("two.mp3");
// Print name of file that's playing
Serial.println(DF1201S.getFileName());
DF1201S.playSpecFile("three.mp3");
// Print name of file that's playing
Serial.println(DF1201S.getFileName());

It always plays the same song and to boot, I get Chinese characters displayed for the file name. Clearly, not what I was trying to play.

However, make a minor change to the filename and this works.


// Play file
DF1201S.playSpecFile("/one.mp3");
// Print name of file that's playing
Serial.println(DF1201S.getFileName());
DF1201S.playSpecFile("/two.mp3");
// Print name of file that's playing
Serial.println(DF1201S.getFileName());
DF1201S.playSpecFile("/three.mp3");
// Print name of file that's playing
Serial.println(DF1201S.getFileName());

This plays three different songs correctly and their filenames are reported accurately.

HTH everyone 🙂




If you'd like to subscribe to this blog, please click here.