background image

 

Venus Supply Co., Ltd.                                                                            Page 11

 

 

Example 2

 In parallel mode, send a command to play 002.mp3 in folder 03. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

const int P0 = 2; 
const int P1 = 3; 
const int P2 = 4; 
const int P3 = 5; 
const int P4 = 6; 
const int P5 = 7; 
const int P6 = 8; 
const int P7 = 9; 
const int BUSY = A4;  
const int PL = A5; 
 
void set_port() { 
  pinMode(P0, OUTPUT); 
  pinMode(P1, OUTPUT); 
  pinMode(P2, OUTPUT); 
  pinMode(P3, OUTPUT); 
  pinMode(P4, OUTPUT); 
  pinMode(P5, OUTPUT); 
  pinMode(P6, OUTPUT); 
  pinMode(P7, OUTPUT); 
  pinMode(PL, OUTPUT); 
  pinMode(BUSY,INPUT); 

void send_CMD(unsigned char cmd) { 
  if( cmd&0x01 ) digitalWrite(P0, HIGH); //Bit 0 
    else digitalWrite(P0, LOW); 
  if( cmd&0x02 ) digitalWrite(P1, HIGH); //Bit 1 
    else digitalWrite(P1, LOW); 
  if( cmd&0x04 ) digitalWrite(P2, HIGH); //Bit 2 
    else digitalWrite(P2, LOW); 
  if( cmd&0x08 ) digitalWrite(P3, HIGH); //Bit 3 
    else digitalWrite(P3, LOW); 
  if( cmd&0x10 ) digitalWrite(P4, HIGH); //Bit 4 
    else digitalWrite(P4, LOW); 
  if( cmd&0x20 ) digitalWrite(P5, HIGH); //Bit 5 
    else digitalWrite(P5, LOW); 
  if( cmd&0x40 ) digitalWrite(P6, HIGH);  //Bit 6 
    else digitalWrite(P6, LOW); 
  if( cmd&0x80 ) digitalWrite(P7, HIGH);  //Bit 7 
    else digitalWrite(P7, LOW); 

  delay(100); digitalWrite(PL, LOW); 
  delay(100); digitalWrite(PL, HIGH); 

boolean cmd_stop =false ; 

void setup()  { 
  set_port(); 

void loop()  { 
  if ((digitalRead(BUSY) == HIGH) && (cmd_stop == false)) { 
     send_CMD(0xF3);   
     delay(200); 
       while(digitalRead(BUSY) == HIGH) {   
         send_CMD(0x02);  
         cmd_stop=true; 
       } 
    } 

  3. Set data pins according to sending command  

5. 

When BUSY is “High”, send 0xF3 

 

and 0x02 to the module. To change  
directory to 03 and play file 002.mp3. 

 

1. Pin assignments

 

2. Pins

 direction assignments 

4. Call set_port() 

to set pins’ direction

 

Summary of Contents for MP3

Page 1: ...User Manual ThaiEasyElec MP3 Embedded Module Version 1 2 ...

Page 2: ...Venus Supply Co Ltd Page 1 Revision History Version Date Changes 1 2 4 June 2014 Wording Correction 1 1 16 November 2013 Image chaged Usage with Arduino added 1 0 3 October 2013 Original Version ...

Page 3: ...e quality sound with 8 kHz 48 kHz sampling rate The user can use any MCU to control the module using parallel or serial interface With MP3 files stored on a SD card the user can select a sound folder select a file start playback and control play volume using simple serial or parallel commands The SD card can be as large as 32 GByte The module is well suited many applications such as queuing system...

Page 4: ...B Sampling rates 8 kHz 48 kHz Accept 5 VDC power supply Use 20 pin 2 54mm pitch header for interface Dimension 35x51 mm Electrical Characteristic Parameter Min Typ Max Unit Operating voltage 4 5 9 V Operating current 150 mA Input voltage 3 1 5 3 V Output voltage 3 1 V Audio Distortion rate 0 005 0 05 Audio Dynamic range 90 dB Audio Max output level 0 6 0 75 Vrms 35 mm 51 mm 3 5 mm 3 5 mm ...

Page 5: ... STM8S103 No 7 Micro SD Card Socket No 8 Interface Header see detail below Pin No Pin Name Description 1 8 P0 P7 Data Input 9 VOL Volume down 10 VOL Volume up 11 RESERVE 12 RESERVE 13 BUSY Busy low active 14 PL Trigger Input low active 15 RXD Serial port receiver input 16 TXD Serial port transmitter output 17 HPR Audio output right 18 HPL Audio output left 19 GND Ground 20 5V 5V Power input ...

Page 6: ...e 15 folders on a SD card with names 02 03 15 The root directory is considered as the folder 1 File ordering example From figure above there are 4 files and the file 017 mp3 is counted as the 3rd file So the user has to play it using command 0x03 Note BUSY Pin BUSY is driven low on initialization state and when a file is being played In all other case the pin is driven high PL Pin PL is the trigge...

Page 7: ...and 0xF4 Change to folder 4 As illustrated it s recommended to name all files and folders sequentially 2 Select the operating mode Serial Parallel 2 1 To use Parallel mode M0 and M1 must be connected to GND as shown below zero ohm resistors are used here By default the module is configured in parallel mode 2 2 To use Serial mode remove M0 and leave M1 connected to GND See image below ...

Page 8: ...ata PL and BUSY Optionally VOL and VOL can be connected to switches for increasing or decreasing the volume directly The connections are described below MP3 module Pin Device 5V 5V Arduino GND GND Arduino P0 P7 D2 D9 Arduino BUSY A4 Arduino PL A5 Arduino VOL Switch 1 VOL Switch 2 HP_L Left Audio Jack HP_R Right Audio Jack Data In 8 Bits BUSY PL 5V GND Switch Vol Switch Vol HP_L HP_R ...

Page 9: ...file 1 1 0 0 0 1 1 1 0xC7 199 Play the 199th file 1 1 0 0 1 0 0 0 0xC8 200 Set volume level to 0 the lowest level 1 1 0 0 1 0 0 1 0xC9 201 Set volume level to 1 1 1 1 0 0 1 1 1 0xE7 231 Set volume level to 31 the highest level 1 1 1 0 1 0 0 0 0xE8 232 Increase volume by 1 level 1 1 1 0 1 0 0 1 0xE9 233 Decrease volume by 1 level 1 1 1 0 1 0 1 1 0xEB 235 Pause playback 1 1 1 0 1 1 0 0 0xEC 236 Resu...

Page 10: ...Mode P6 OUTPUT pinMode P7 OUTPUT pinMode PL OUTPUT pinMode BUSY INPUT boolean cmd_stop false void setup set_port void loop if digitalRead BUSY HIGH cmd_stop false digitalWrite P0 HIGH digitalWrite P1 LOW digitalWrite P2 LOW digitalWrite P3 LOW digitalWrite P4 LOW digitalWrite P5 LOW digitalWrite P6 LOW digitalWrite P7 LOW delay 100 digitalWrite PL LOW delay 100 digitalWrite PL HIGH cmd_stop true 1...

Page 11: ...le once 4 When BUSY is High set data pins to 0x01 to the module and send Low strobe pulse void set_port pinMode P0 OUTPUT pinMode P1 OUTPUT pinMode P2 OUTPUT pinMode P3 OUTPUT pinMode P4 OUTPUT pinMode P5 OUTPUT pinMode P6 OUTPUT pinMode P7 OUTPUT pinMode PL OUTPUT pinMode BUSY INPUT void setup set_port void loop if digitalRead BUSY HIGH cmd_stop false digitalWrite P0 HIGH digitalWrite P1 LOW digi...

Page 12: ...Write P2 HIGH Bit 2 else digitalWrite P2 LOW if cmd 0x08 digitalWrite P3 HIGH Bit 3 else digitalWrite P3 LOW if cmd 0x10 digitalWrite P4 HIGH Bit 4 else digitalWrite P4 LOW if cmd 0x20 digitalWrite P5 HIGH Bit 5 else digitalWrite P5 LOW if cmd 0x40 digitalWrite P6 HIGH Bit 6 else digitalWrite P6 LOW if cmd 0x80 digitalWrite P7 HIGH Bit 7 else digitalWrite P7 LOW delay 100 digitalWrite PL LOW delay...

Page 13: ...f cmd 0x01 digitalWrite P0 HIGH Bit 0 else digitalWrite P0 LOW if cmd 0x02 digitalWrite P1 HIGH Bit 1 else digitalWrite P1 LOW if cmd 0x04 digitalWrite P2 HIGH Bit 2 else digitalWrite P2 LOW if cmd 0x08 digitalWrite P3 HIGH Bit 3 else digitalWrite P3 LOW if cmd 0x10 digitalWrite P4 HIGH Bit 4 else digitalWrite P4 LOW if cmd 0x20 digitalWrite P5 HIGH Bit 5 else digitalWrite P5 LOW if cmd 0x40 digit...

Page 14: ...NO R3 EADN014 using 3 signals TX RX and BUSY จากภาพจะเห นได ว า มีบอร ด Arduino UNO R3 EADN014 ต อกับโมดูล MP3 ดังนี MP3 module Pin Device 5V 5V Arduino GND GND Arduino TX D4 Arduino RX D3 Arduino BUSY D5 Arduino VOL Switch 1 VOL Switch 2 HP_L Left Audio Jack HP_R Right Audio Jack TX D4 RX RX D3 TX D5 BUSY PH_L PH_R GND 5V ...

Page 15: ...DEC 0x01 001 Play the first file 0x02 002 Play the second file 0xC7 199 Play the 199th file 0xC8 200 Set volume level to 0 the lowest level 0xC9 201 Set volume level to 1 0xE7 231 Set volume level to 31 the highest level 0xE8 232 Increase volume by 1 level 0xE9 233 Decrease volume by 1 level 0xEB 235 Pause playback 0xEC 236 Resume playback 0xEF 239 Stop playback 0xF1 241 Change directory to 01 Roo...

Page 16: ...es High and cmd_stop is false a command 0x01 will be sent via serial port Then cmd_stop is set to true This will command the module to play the first file once include SoftwareSerial h SoftwareSerial mySerial 3 4 RX TX const int BUSY 5 boolean cmd_stop false void setup pinMode BUSY INPUT mySerial begin 9600 void loop if digitalRead BUSY HIGH cmd_stop false Serial write 0x01 cmd_stop true include S...

Page 17: ... again and a command 0x02 is sent to play 002 mp3 void loop if digitalRead BUSY HIGH cmd_stop false mySerial write 0xF3 delay 200 while digitalRead BUSY HIGH mySerial write 0x02 cmd_stop true include SoftwareSerial h SoftwareSerial mySerial 3 4 RX TX const int BUSY 5 boolean cmd_stop false void setup pinMode BUSY INPUT mySerial begin 9600 void loop if digitalRead BUSY HIGH cmd_stop false mySerial ...

Reviews: