I created a library for use with the MDFLY MP3 module. It is apparently the same as a Tenga TDB380 module, but there are some differences between the commands. My library works on any pin, so it doesn't take up the serial port.
On my MDFLY module, retrieving the number of files in a folder works, but in the Tenga datasheet it says these commands are no longer valid. My library has no receive method, so either way you can't get the result. I did it that way because it was much simpler and smaller code and since those types of commands are supposed to be invalid anyway...
Constructor:
serMP3 mp3(10,11) //TX pin, Busy Pin
Methods are:
begin(00-31) //intializes the module and sets the initial volume
play(001 -199)
pause()
stop()
playRand()
volUP()
volDN()
setVol(00-31)
cd(01-15) //Change directory
send(byte) //I made this function public so that you can send other commands if they happen to be supported by your module)
checkBsy() //gets the status of the Busy pin
Here is my example sketch:
#include <serMP3.h>
//union serial_data {
// unsigned long number;
// byte read_byte[3];
//} data;
serMP3 MP3(11,10);
void setup(){
MP3.begin(31);
Serial.begin(9600);
}
void loop(){
byte sc = 0;
unsigned long number = 0;
byte n =0;
if(Serial.available()){
sc = Serial.read();
}
if(sc == 'p' || sc == 'P'){ //Play (001-199)
number=Serial.parseInt();
n = byte(number);
MP3.play(n);
}
if(sc == 's' || sc == 'S'){ //Stop Playing
MP3.stop();
}
if(sc == '+'){ //Voume Up
MP3.volUP();
}
if(sc == '-'){ //Volume Down
MP3.volDN();
}
if(sc == 'v' || sc == 'V'){ //Set Volume (01-31)
number=Serial.parseInt();
n = byte(number);
MP3.setVol(n);
}
if(sc == 'f' || sc == 'F'){ //Change Directory (01-15) 01 is root
number=Serial.parseInt();
n = byte(number);
MP3.cd(n);
}
if(sc == '*'){ //Play a random file (will switch back to the root folder! Only plays from root folder)
MP3.playRand();
}
if(sc == '/'){ //Pause/Resume
MP3.pause();
}
}
Hopefully someone finds it useful. Parts of this were taken from the softwareSerial library, but heavily modified and will not interfere with it.