Skip to content

DFRduino_Player_V2_(SKU__TOY0008)

Angelo edited this page Sep 21, 2016 · 3 revisions

 DFRduino Player module

Introduction

The DFRduino Player module is an MP3 module compatible with the .net gadeteer interface. The Player is able to play MP3/WAV/Midi audio files from a micro SD card. It supports two kinds of interfaces: UART and .net gadgeteer allowing communication with a range of microcontrollers. All you need to do is load audio files onto SD card and the microcontroller will play files by sending the relevant name of audio files to the module. The player also supports PC control. In addition, this module provides a port which will output a high logic level after finishing a track.

Specification

  • Working Voltage: 5V
  • Working Current: >200mA(with load)
  • Output Load: recommended 4Ω, 8Ω
  • Output Power: 3W per channel(4Ω)
  • Control Interface: UART, PIN Header and .net gadgeteer
  • UART Format: 19200/8/N/1
  • Supported Media: MP3,WAV,MIDI
  • Supported SD Card: Micro SD Card
  • Module Size: 52 x 37mm

Pinouts

 DFRduino Player module

  • PIN Header:
    • 1.+5V - Positive voltage
    • 2.GND - Ground
    • 3.RX - UART Receive
    • 4.TX - UART Transmit
    • 5.OUT - Output 1ms Low logic level at the end of a track
  • .Net Gadgeteer Interface: U type (5V)
  • Speaker Port:
    • L_SP - Left channel
    • R_SP - Right channel
  • Indicator: It will stay on after initialization. The indicator will flash and serial will output "Please check micro SD card\r\n" if SD card cannot be used.

Attention

  • The SD card must be formatted at FAT32
  • There must be a root directory named "sound" where audio files are stored
  • File names must not exceed 8 letters
  • Current should higher than 1000mA if you intend to use two speakers
  • UART must be set at 19200bps.

Support Commands

  • Play music via receiving filename command "filename\r\n" Return "Play ok\r\n" if success. Return "Not found\r\n" if failed to find the file. (Note: "filename" is not include file extension)
  • Return "over\r\n" if finish playing one song.
  • Pause Play "\:p\r\n" Return "pause\r\n" if success
  • Continue Play "\:s\r\n" Return "start\r\n" if success
  • Play next "\:n\r\n" Return "next\r\n" if success,Return "false\r\n" if failed
  • Play previous "\:u\r\n" Return "key up\r\n"
  • Set the volume "\:v 255\r\n",set the volume, from 0 (minimum)-255 (maximum), Return "vol set ok" if success

Tutorial

Smart Player

a) Objective: Make a player that can Play, Play Next, Play Previous, Pause, Continue.

b) Hardware List

  • DF_UNO 1
  • ADKeyboard 1
  • Speakers x 2
  • DFRduino Player module x 1
  • Micro SD Card Reader x 1
  • Jumper wires

c) Software List

d) Connection Diagram center

e) Method

  1. Copy songs into the "sound" directory of SD card
  2. Insert SD card into the module
  3. Open Arduino IDE
  4. Upload code to microcontroller (Note: There is only one Serial port on the UNO - you cannot connect DFRduino Player to UNO when uploading)
  5. Connect modules together (It is better to use an external power source than USB power)
// # Description:
// # This sample code is for testing DFRduino Player Module to realize MP3 player.

// # Connection:
// #    TX              RX
// #    RX              TX
// #    5V              +5V
// #    GND             GND
// #    ADKeyBoard      Anolog 0


int adc_key_val[5] ={50, 200, 400, 600, 800 };
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;

void setup()
{
  Serial.begin(19200);
  delay(2000);          //Wait for initialization
  Serial.println("\\:v 200");    // set the volume, from 0 (minimum)-255 (maximum)
  delay(50);
}


void loop()
{
  adc_key_in = analogRead(0);    // read the value from the sensor

  key = get_key(adc_key_in);     // convert into key press

  if (key != oldkey)      // if keypress is detected
   {
    delay(50);      // wait for debounce time
    adc_key_in = analogRead(0);    // read the value from the sensor
    key = get_key(adc_key_in);     // convert into key press
    if (key != oldkey)
    {
      oldkey = key;
      if (key >=0){
        switch(key)
        {
           case 0:
                  Serial.println("\\:p"); // Pause
                  break;
           case 1:
                  Serial.println("\\:s");// Continoue to play
                  break;
           case 2:
                  Serial.println("\\:n");  // Play next
                  break;
           case 3:
                  Serial.println("\\:u"); // Play previous
                  break;
           case 4: //Play
                  Serial.println("\\yours");  //name of song

                  break;
        }
      }
    }
  }
 delay(100);
}

// Convert ADC value to key number
int get_key(unsigned int input)
{
    int k;

    for (k = 0; k < NUM_KEYS; k++)
    {
      if (input < adc_key_val[k])
      {
            return k;
      }
   }
    if (k >= NUM_KEYS)k = -1;  // No valid key pressed
    return k;
}

image:nextredirectltr.pngGo shopping dfrduino player module(.net gadgeteer compatible) (sku:toy0008)

category: TOY Series

Clone this wiki locally