Along with an MP3 player circuit came a bunch of documentation, but, I’m having trouble with some commands because I don’t know what the acronyms stand for so I can insert a value. See, I want to be able to play a specified song based on parameters in the program running on my UNO.
In the documentation below, there are S.N.H. S.N.L. and SM.What are they?
Please help me to know what the acronyms stand for.
It seems that one or more of you have messed with a MP3 player similar to this.
With what you said above, I tried a few things and just can't get it to work the way I think I understand it should.
All of the songs on the micro SD chip are named 00001.mp3, 00002.mp3--00011.mp3, if that is important. I sent several Next commands and the player did play the next song. on the 3rd song, I sent a 'query current song' command (AA 0d 00 b7) and it sent back AA 0D 02 00 03 BC. From that I assumed S.N.L. was 00, S.N.H. was 03 and SM was BC. With that information I sent a couple more of Next commands then a 'Specified Song' command (AA 07 02 00 03 BC). Note, I used the 00 03 BC that had been returned in the query. Nothing played. Not the requested song nor any song. I sent a Play command (AA 02 00 AC). It played the last song that had played before, not the one that I wanted.
See, I have certain songs that are associated with particular functions in the UNO. I want to sent the correct serial command but I'm not getting there.
I'm asking for more help. Help to come up with the command to play a specific song.
Using what you posted, I was able to select specific songs all over and it played.
These little boards are currently less than $3. each from China and have a bunch of options (if you can figure out the documentation). If you want to mess with one, message me and I'll point you to the URL.
Maybe just one more thing and this regards to, writing a program, as an exercise, on my UNO to step through the songs.
With the help provided previously, the hex AA 07 02 00 0A BD should play the 10th song on my MP3 player, and it does when I use SerialPortUtility.
Because I'm new at this, I look at examples but many times they confuse me. I found one example writing HEX data but they just execute the Serial.print 5 times. I used their example below but it dod NOT work (the MP3 Player did not respond. I connected the OUN Tx & Rx to the MP3 player's Rx & Tx respectfuly.
/*
Arduino serial send hex information test code
This code will send AA 07 02 00 01 B3 to the MP3 player
then increment the last 2 hex numbers and send again and again...
*/
byte StCode = 0xAA;
byte ComType = 0x07;
byte DataLngth = 0x02;
byte DataN = 0x00;
byte Song = 0x00;
byte CkBit = 0xB3;
byte X = 0x00;
byte A = 0x00;
byte T = 0x00;
byte DL = 0x00;
byte D1 = 0x00;
byte D2 = 0x00;
byte CB = 0x00;
void setup() {
Serial.begin(9600);
// Serial1.begin(9600);
while (!Serial); // while not open, do nothing. Needed for Leonardo only
}
void loop()
{
X = X + 1;
A = StCode;
T = ComType;
DL = DataLngth;
D1 = DataN;
D2 = Song + X;
CB = CkBit + X;
Serial.print(A, HEX); // send A out serial
Serial.print(T, HEX); // send T out serial
Serial.print(DL, HEX); // send DL out serial
Serial.print(D1, HEX); // send D1 out serial
Serial.print(D2, HEX); // send D2 out serial
Serial.print(CB, HEX); // send CB out serial
delay(5000); // wait for 5 seconds to send again
if (X > 49); {
X = 0; }
}
Is there a better way to Tx over the serial port or is there a more efficent way?
not saying it's better, not saying it's not. just saying, this is how I do it.the following code is for a YX-5300 module:
//( on top, after #include <libraries> and before void_setup(); )
static unsigned int Send_buf[8] = {0}; // char string for YX-5300 commands
//the function:
void sendCommand(uint8_t command, int16_t dat)
{
Send_buf[0] = 0x7e; //starting byte
Send_buf[1] = 0xff; //version
Send_buf[2] = 0x06 ; //the number of bytes of the command without starting byte and ending byte
Send_buf[3] = command; //
Send_buf[4] = 0x00; //0x00 = no feedback, 0x01 = feedback
Send_buf[5] = (int8_t)(dat >> 8);//data high byte
Send_buf[6] = (int8_t)(dat); //data low byte
Send_buf[7] = 0xef; //ending byte
for (uint8_t i = 0; i < 8; i++) //
{
Serial2.write(Send_buf[i]);
//lcd1.setCursor(6, 3); lcd1.print(" "); lcd1.setCursor(6, 3); lcd1.print(dat >> 8, HEX); // bottom center
//lcd1.setCursor(8, 3); lcd1.print(" "); lcd1.setCursor(8, 3); lcd1.print(dat & 15, HEX); // of top LCD
}
}
you can change the values behind Send_buf[X] to suit your module. the lcd1.et cetera that is behind the // is for troubleshooting. not necessary, sometimes helpful.
I did a lot of searching and learning, after all, that is what working with Arduinos is suppose to be about.
One of my problems was the monitor in the IDE. It didn't reflect what was being sent because it doesn't have a HEX option, I guess. So I used SerialPortUtility. SerialPortUtility does interfere with uploading but changing the com port before uploading and back after worked.
Here is some code I worked on and got to work. More of an exercise to see what I can do. It just plays 8 seconds of the first 50 MP3s. Any or part of the code can be changed to do what is needed or build a function.
BTW: On this board, the MP3s don't have to be named 0001.mp3, 0002.mp3... I used a micro SD chip with regular song titles and it worked. I guess the issue is stacking the directory so you can find the right MP3 just by what position in the directory it is. I guess I'll have to learn that next.
This code can be cleaned up, the first MP3 is played twice.
/*
Arduino serial send hex information test code
This code will send AA 07 02 00 01 B3 then increment the 5th hex number
and calculate a new CheckSum required for the MP3 player board.
*/
byte X = 0x00;
byte Max = 0x50;
byte VolLvl = 0x14; //14 is hex for 20 decimal
byte MP3[] = {0xAA, 0x07, 0x02, 0x00, 0x01, 0xB4};
byte Vol[] = {0xAA, 0x13, 0x01, 0x14, 0xD2}; // sets volume 3/4
void setup(){
Serial.begin(9600); // Serial1.begin(9600);
while (!Serial); // while not open, do nothing. Needed for Leonardo only
}
void loop(){
for(X = 1;X <= Max;X++) { //statements block will executed Max times
Serial.write(Vol, 5); // Write to TX port to set volume
Serial.write(MP3, 6); // Write to TX port to play MP3
delay(8000); // wait for 8 seconds to send again
MP3[4] = X; // Set Song for next
MP3[5] = MP3[0] + MP3[1] + MP3[2] + MP3[3] + MP3[4] ; // Calculate CheckSum
}
}
If anyone is interested in this board or the complete documentation, message me. I want to help where I can.