DFRduino_Player_V2_(SKU_TOY0008) - jimaobian/DFRobotWiki GitHub Wiki
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.
- Working Voltage: 5V
- Working Current: >200mA(with load)
- Output Load: recommend 4Ω, 8Ω
- Output Power: 3W per channel(4Ω)
- Control Interface: UART, PIN Header and Gadgeteer
- UART Format: 19200/8/N/1
- Support Media: MP3,WAV,MIDI
- Support SD Card: Micro SD Card
- Module Size:52x37mm
- PIN Header:
- 1.+5V - Positive power
- 2.GND - Negative power
- 3.RX - Receive port of UART
- 4.TX - Transmit port of UART
- 5.OUT - Output 1ms Low level at the end of the play
- Gadgeteer Interface: U type (5V)
- Speaker Port:
- L_SP - Left channel
- R_SP - Right channel
- Indicator: It will keep on after initialization. The indicator will flash and Serial will output "Plese check micro SD card\r\n" if SD card cannot be used.
- The SD card must be formated at FAT format.
- MUST create a "sound" directory
- Put mp3/wav/midi files in the "sound"
- Make sure the length of file name do not exceed 8 letters.
- The current should higher than 1000mA if use two speakers
- UART must be set 19200bps.
- 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
a) Target: Make a Player that can Play, Play Next, Playe Previous, Pause, Continue.
b) Hardware List
- DF_UNO 1
- ADKeyboard 1
- Speaker 2
- DFRduino Player module 1
- micro SD Card Reader 1
- Dupont Wires
c) Software List
d) Connect Diagram
e) Step by Step
- Copy songs into "sound" directory of SD card.
- Insert SD card into the module.
- Open Arduino IDE.
- Upload code to UNO (Note: There is only one Serial on UNO. Cannot connect DFRduino Player to UNO when upload)
- Connect modules together. It is better to use an external 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;
}
shopping dfrduino player module(.net gadgeteer compatible) (sku:toy0008)