Introduction

This DFRduino Player module is a MP3 module compatible with .net gadeteer.The Player is able to play MP3/WAV/Midi sound tracks on SD card. It supports two kinds of interfaces UART and gadgeteer which allow other microcontroller to talk to the player. You just put the audio files into SD card. Arduino or other microcontroller will play the audio files by sending the relevant name of audio files. The play is thus able to be controlled by PC. In addition,this module provides a port which will output high level after fishing a song.Now, it is the time to make your project talk with DFRduino Player module.

Specification

Diagram

DFRduino Player module

OUT:output 1ms Low level after finish a song

Attention

Support Commands

Sample Code 1

// Product name: DFRduino Player Module
// # Product SKU :TOY0008
// # Version     : 0.1

// # Description:
// # This sample code is for testing DFRduino Player Module

// # Connection:
// #   Arduino     MP3
// #    TX         RX
// #    RX         TX
// #    5V          5V
// #    GND        GND

// # Support Commands:
// #        1. Pause Play "\:p\r\n" Return "pause\r\n" if success
// #        2. Continoue Play "\:s\r\n" Return "start\r\n" if success
// #        3. Play next "\:n\r\n" Return "next\r\n" if success,Return "false\r\n" if failed
// #        4. Play previous "\:u\r\n" Return "key up\r\n"
// #        5. Set the volume "\:v 255\r\n",set the volume, from 0 (minimum)-255 (maximum), Return "vol set ok" if success
void setup() {
  Serial.begin(19200);
  delay(2000);
  Serial.println("\\:v 200");    // Set the volume to the maxmum, range: 0-255 =
  delay(50);
}

void loop() {
  delay(5000);
  Serial.println("\\:n");  // play next song
}

Sample Code 2

// # 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 2 seconds
  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
                  Serial.println("OK");
                  break;
           case 1:
                  Serial.println("\\:s");// Continoue to play
                  Serial.println("OK");
                  break;
           case 2:
                  Serial.println("\\:n");  // Play next
                  Serial.println("OK");
                  break;
           case 3:
                  Serial.println("\\:u"); // Play previous
                  Serial.println("OK");
                  break;
           case 4: //Play
                   //The volume must be set before playing the sound
                  Serial.println("\\:v 200");    // set the volume, from 0 (minimum)-255 (maximum)
                  Serial.println("\\yours");
                  Serial.println("OK");
                  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;
}

More Documents

DFshopping_car1.png Get DFRduino Player module(.NET Gadgeteer Compatible) (SKU:TOY0008) from DFRobot Store or DFRobot Distributor.

Turn to the Top