Introduction

The Player is able to play MP3/WAV/Midi sound track on SD card. It supports two interface UART/I2C which lets other microcontroller to talk to the player.

The player support both I2C and UART interface (via jumper). The play is thus able to controled by PC. A TTL/USB converter is required.

Specification

DFR0112-4.jpg

UART/I2C Mode Switch

DFR0112_(2).jpg

The interface mode of Player can be switched via the jumper.

The green led will flash once which means the player is under UART(Serial) mode when the player startup. The green led will flash twice which means the player is under I2C mode. Once the Player is ready the green LED will stay lit

I2C pin connection:

Analog Pin4 (SDA) goes to DO

Analog Pin5 (SCL) goes to DI

Support SD Cards

The player has been tested with micro SD card (1G).

The SD card must be formatted at FAT format, not FAT32.

If the green led is flashing all the time which means the SD card is not ready, either not supported or not correctly formatted. And string "\Plese check micro SD card\r\n" will be returned in UART mode.

the player will only work if:

the blinking light signals not only problems reading the card, but it will also blink if there is no "\sound" directory or if there are no playable files in that directory.

If the green led do not flash, it means the SD card is working properly.

Support Commands

Connection Diagram

DFR0112 connection diagram---IIC DFR0112 connection diagram---UART

Sample

IIC Mode

Put jumper to IIC mode. Connect the player to Arduino board via IIC. Burn the sample code to the board. Open the serial monitor of Arduino and send commands: p--pause s--continue n--next song u--previous song m--play song named"yes" Note that no return except "OK" is returned under IIC mode.


#include <Wire.h>
#include <stdlib.h>

#define ArduinoPlayer_address 0x35  //ArduinoPlayer I2C address 0x35 (default)

void TwiSend(const char  *cmd)  //I2C Command
{
  char len = 0;
  len = strlen(cmd); //Calculate the length of the command
  Wire.beginTransmission(ArduinoPlayer_address); // ArduinoPlayer I2C address
  while(len--)
  {
    Wire.send(*(cmd  ));
  }
  Wire.endTransmission();    // stop transmitting
}
void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
  Serial.begin(9600);
  delay(2000);//Wait for 2 seconds
  Serial.println("Ready");
  TwiSend("\\:v 255\r\n");    // set the volume, from 0 (minimum)-255 (maximum)
}

//Receive control command from serial
void loop()
{
  int val;
  if(Serial.available() > 0)
  {
    val=Serial.read();
    switch(val)
    {
    case 'p':      // Pause
      TwiSend("\\:p\r\n");
      Serial.println("OK");
      break;
    case 's':     // Continoue to play
      TwiSend("\\:s\r\n");
      Serial.println("OK");
      break;
    case  'n':
      TwiSend("\\:n\r\n");  // Play next
      Serial.println("OK");
      break;
    case 'u':
      TwiSend("\\:u\r\n"); // Play previous
      Serial.println("OK");
      break;
    case  'm':      //Play
      //The volume must be set before playing the sound
      TwiSend("\\:v 250\r\n");    // set the volume, from 0 (minimum)-255 (maximum)
      TwiSend("\\yes\r\n");
      Serial.println("OK");
      break;
    default:
      break;
    }
  }
}

UART MODE

Put jumper to IIC mode. Connect the player directly to computer via TTL-USB converter. We can use any serial communication assistant to send commands, or use Arduino serial monitor. The baud of communication is 19200 if not changed.

Considering the correctness of data, we recommend to send controls in ASCII HEX code. Next song: 5C 3A 6E 0D 0A Previous song: 5C 3A 75 0D 0A pause: 5C 3A 70 0D 0A Start: 5C 3A 73 0D 0A Volume set: 5C 3A 76 20 (32 35 35) 0D 0A Change the volume as your wish. (Notation: 32 35 35 is ASCII HEX code of "255", you can change it from 0-255. However, we suggest range from 200 to 255 since the sound is quite low under 200.) Song choice mode: 5C (...) 0D 0A. We can play any song in SD card if you know the song name.(...) should be replaced by HEX code of song name. For example, if the song name is 'sky', (...) can be replaced by 73 6B 79.)

Screenshot of window terminal

warning_yellow.png NOTE: You must choose the "Both NL & CR" choice in the Serial monitor(the drop-down menu beside the baudrate choice menu)。 After this step you command will be transmitted with "\r\n"(The new line command bytes).

Original Source code

Warning: We provide the source code for those of you with advanced coding skills. It is provided as is and with no support. DOWNLOAD AND PLAY AT YOUR OWN RISK!

DFRduino Player Source Code

User contributions

This is a link to a VB.Net GUI for the DFRduino player.

Player GUI -contributed by user: mtrethowan

More Documents

DFshopping_car1.png Get DFRduino player from DFRobot Store or DFRobot Distributor.

Turn to the Top