
#Mp3 player arduino serial#
If there a char on Serial call sendMP3Command to sendCommand #define CMD_SET_SNGL_CYCL 0X19 // Set single cycle. #define CMD_SNG_CYCL_PLAY 0X08 // Single Cycle Play. #define CMD_PREV_SONG 0X02 // Play previous song. #define CMD_NEXT_SONG 0X01 // Play next song.

String mp3Answer // Answer from the MP3.īoolean playing = false // Sending 'p' the module switch to Play to Pause or viceversa. Static int8_t pre_vol, volume = 0x0f // Volume. Would this work?: if (digitalRead=some specific IR code) // Buffer for the answers. The cloud I'm making will be controlled via an infrared remote, triggering different functions. If you were to implement the mp3-capabilities in the void loop, how would you do it? Have I understood it right, that if the command: CMD_PLAY_W_VOL, 0X 1E01, would play the first song at volume 30 then? Because 30 = 1E in hexadecimal? It seems (from the manual) that you are also able to play specific tracks on the SD card.īut you are right in that it's tricky to understand the feedback mechanism. To answer your question, the micro SD card slot is located on the mp3 player module. Thank you for taking the time explaining this for me. If you want to play the second file on the SD card, try changing 0x0f01 to 0x0F02, and see what you get. The second byte is 01, which is hexadecimal for 1, and means play the first file, apparently. The first byte is 0F, which is hexadecimal for 15, and has something to do with volume. From the context, it appears that this 16 bit data value is actually two separate bytes stuck together.

The 0x0F01 means a 2-byte integer, with the hexadecimal value 0F01. The second is the "data", which is a number which would mean different things for different commands. The first is the "command", and the available commands would appear to be shown by the #define's. There are two meaningful components of your command message to the device. You would need some kind of documentation for the device to understand all of the possible commands that the device might have. The format and contents of those messages would be defined by the device. What is going on there, is that the arduino is sending 8-byte serial messages to the device.
#Mp3 player arduino code#
I don't see any code there for an SD card, is the SD connected to the arduino or directly connected to the device ? I can make it play the mp3 files on my SD card (following the code), Send_buf = 0x00 //0x00 = no feedback, 0x01 = feedback Send_buf = 0x06 //the number of bytes of the command without starting byte and ending byte Void sendCommand(int8_t command, int16_t dat) SendCommand(CMD_PLAY_W_VOL, 0X0F01) //play the first song with volume 15 class SendCommand(CMD_SEL_DEV, DEV_TF) //select the TF card

SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX) ĭelay(500) //Wait chip initialization is complete #define ARDUINO_TX 6//connect to RX of the module #define ARDUINO_RX 5//should connect to TX of the Serial MP3 Player module
#Mp3 player arduino how to#
I have trouble understanding the example code, and I was wondering if you guys could help me a bit? I can make it play the mp3 files on my SD card (following the code), but I don't know how to control it further than that. It's a MP3 serial player module (bought on dx.com). Until now, I have been able to get the "lightning" running pretty decently, but my newest addition is causing me troubles. My main reason for wanting to learn Arduino, was to be able to make a cloud sculpture complete with lightning and speakers inspiration from this guy.

Now I have finished all of the beginners' tutorials and I am beginning to make some projects on my own. I recently took up arduino, and bought a kit of different components.
