![]() |
Forum Index : Microcontroller and PC projects : catalex MP3 Module
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
I am trying to play with this module connected to com port on uMite. For the life of me I can not get it to respond and am not sure exactly how to send the 8 byte hex commands over the com port. I can't tell by the manual if each byte is separated by a space either. This is a sample code that they provided for arduino, but not making sense to me... /*********************************************************** /
//Demo for the Serial MP3 Player by Catalex //Hardware: Serial MP3 Player *1 //Board: Arduino UNO R3 //IDE: Arduino-1.0 //Function: To play the first song in the micro sd card. //Store: http://www.aliexpress.com/store/1199788 // http://www.dx.com/ #include <SoftwareSerial.h> #define ARDUINO_RX 5//should connect to TX of the Serial MP3 Player module #define ARDUINO_TX 6//connect to RX of the module SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX); static int8_t Send_buf[8] = {0} ; #define CMD_SET_VOLUME 0X06 #define CMD_PLAY_W_INDEX 0X08 #define CMD_SEL_DEV 0X09 #define DEV_TF 0X02 #define CMD_PLAY 0X0D #define CMD_PAUSE 0X0E #define CMD_SINGLE_CYCLE 0X19 #define SINGLE_CYCLE_ON 0X00 #define SINGLE_CYCLE_OFF 0X01 #define CMD_PLAY_W_VOL 0X22 void setup() { mySerial.begin(9600); delay(500);//Wait chip initialization is complete sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card delay(200);//wait for 200ms sendCommand(CMD_PLAY_W_VOL, 0X0F01);//play the first song with volume 15 class } void loop() { } void sendCommand(int8_t command, int16_t dat) { delay(20); 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);//datah Send_buf[6] = (int8_t)(dat); //datal Send_buf[7] = 0xef; //ending byte for(uint8_t i=0; i<8; i++)// { mySerial.write(Send_buf) ; } } How do you send Hex data to com port? Would it be something like... PRINT #1, &H7E, &HFF, &H06... for all 8 bytes? Does the comma send a space between the bytes? Here is the pdf manual for the module. It shows spaces between the bytes, but trying to decipher the arduino code, I am not sure if the semi colons supress the space and it just sends one byte after the other. As always, any help is GREATLY appreciated. |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4071 |
Aim to print each as a single char with a ; or else a string so you'd do something like PRINT #1, CHR$(&H7E); PRINT #1, CHR$(&HFF); PRINT #1, CHR$(&H06); or just PRINT #1, CHR$(&H7E)+CHR$(&HFF)+CHR$(&H06); You can always change &H06 to just 6 (and so on). John |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Thank you JohnS, I will give that a whirl!! |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2948 |
Hi viscomjim, As JohnS says, go with PRINT #1, CHR$(&H7E)+CHR$(&HFF)+CHR$(&H06)+........ The sample code you provided is to play the first track on the SD card at volume level 15. The equivalent (and shorter!) code for the MicroMite is as follows: OPEN "COM1:9600" AS #1 'setup COM1 to required 9600 baud PAUSE 500 'wait a bit PRINT #1, CHR$(&H7E)+CHR$(&HFF)+CHR$(&H06)+CHR$(&H09)+CHR$(&H00)+CHR$( &H00)+CHR$(&H02)+CHR$(&HEF); 'select the TF card PAUSE 200 'wait again PRINT #1, CHR$(&H7E)+CHR$(&HFF)+CHR$(&H06)+CHR$(&H22)+CHR$(&H00)+CHR$( &H0F)+CHR$(&H01)+CHR$(&HEF); 'play the first song with volume 15 The above code requires the SD card to be formatted correctly with MP3 files meeting the naming convention as per pdf. Enjoy your music . . . . ![]() WW edit: you may need to drop the semi-colon at the end of each PRINT line - simply try it if the above code doesn't work! |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Thanks WW. I will try and report back. |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
To send midi I use print#1, chr$(123); chr$(231); chr$(132); |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Just gave this a try and the winner is... Print #1, chr$(xx); chr$(xx); etc... I tried this first and it works, I will try the "+" one also to see how that works. Thanks again, success! |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3303 |
This is slightly off topic but... When printing data like this you can use any one of three methods: Print #1, chr$(xx) + chr$(xx) + chr$(xx); Print #1, chr$(xx); chr$(xx); chr$(xx); Print #1, chr$(xx) chr$(xx) chr$(xx); The first concatenates the various characters into a string so the print command sees a single string consisting of three characters (which it outputs). The second presents the print command with three single character strings which it outputs one after the other. If the semicolon is left out between the arguments the interpreter will automatically insert it for you so the third is identical to the second (although not Microsoft compatible). You still need the semicolon at the end to suppress the automatic CR/LF. All three do the same thing (although the first is slightly slower) so you can use whatever "floats your boat". Geoff Geoff Graham - http://geoffg.net |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2948 |
@vicomjim, How are you getting on with playing MP3 tracks? Have you been able to send some of the other commands to do the other things that this module offers? Also, the manual quotes 200mA power requirement - this seems very high even if it has a low power (pre)amp for headphones. Please - can you measure the 'true' current draw figures? WW |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi White, the module is working just great. I started with the mdfly mp3 module and have been working with that for a while. I implemented it into a project and thankfully I purchased about 12 units. When I needed more, I found that they had discontinued it (DAMN!). I think you saw that coming. So in trying to find a replacement, this one came up and I ordered a whole bunch, very inexpensive (YEAH!). I am trying to redo my code right now to use this unit and it is working fine so far. I have used quite a few of the commands and they have all worked so far. I will check the current draw when I get back home. I have to agree, 200ma seems crazy, I highly doubt that is the case. Will keep you posted. P.S. have you tried the NEC cfunction code with the apple remote yet. I'm curious if that works with apple but have not had the opportunity to put a test rig together yet. |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2948 |
Not tried the CFunction for NEC IR; and to be honest, I probably won't be able to unfortunately try it this side of Christmas either. Just to make you aware, I am now in the final stages of preparing for my wedding in December. Time has flown by, and I still have many MicroMite things on my to-do list. For this reason I am trying to not add anything to it unless it is a bpriority. Hopefully someone will try matherp's NEC code - I am curious too as to the results. ![]() WW |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Well congrats to you White!!!! I wish you the best. I will give the cfunction with apple remote a shot and post back. |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9641 |
Yeah, allow me to digress from the topic a little here too, and wish WW a very happy wedding and Christmas - a double whammy for WW. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
G8JCF![]() Guru ![]() Joined: 15/05/2014 Location: United KingdomPosts: 676 |
Very Many Congratulations Phil !! Where did you find the time ![]() Peter The only Konstant is Change |
||||
paceman Guru ![]() Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Congratulations from me too Phil. Don't go taking any Micromites on your honeymoon - unless your intended in a Lady AdA type maybe! Greg |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9641 |
Did you hook up one of your 44's with a lot of LED's in the shape of a heart for the proposal? ![]() ![]() The ole "Beating love-heart" out of red LED's controlled by a microcontroller(or simple transistor oscillator), is actually reasonably effective. Smoke makes things work. When the smoke gets out, it stops! |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2948 |
Thanks everyone - Off to Mauritius next Tuesday (9th Dec); wedding on Sat 20th on the beach. ![]() Before that is my birthday on the 12th; so you guys won't be hearing too much more from me for a while. Anyway, lots to do before next Tuesday . . . . WW |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9641 |
Back on the original topic, I have ordered a couple of these modules to play with. So cheap... I remember when a MP3 player module you could control with a computer or MCU used to cost about $300 - probably as they were not THAT popular in embedded applications then, and just that the technology has got so much cheaper. Smoke makes things work. When the smoke gets out, it stops! |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2948 |
Grogs, Where did you order from please? I will land a couple too . . . |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9641 |
Hi wedding boy. ![]() I got mine from eBay, but it is exactly the same module. US$5.59 each with free shipping. Module Link Smoke makes things work. When the smoke gets out, it stops! |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |