Several projects require sound reproduction to add some kind of functionality. Among these projects, we highlight: accessibility for the visually impaired, MP3 music players and the execution of voice sounds by robots, for example.

In all of these systems, we need an MP3 sound reproduction device to connect to the Arduino.

Therefore, in this article we will learn the following points:

  • Basic operating circuit of the DFMini Player MP3;
  • Organization and configuration of sound files on the memory card;
  • Musical control with Arduino.

To create this project you'll use:

Now, we'll learn how to constructo the project.

What is the DF Mini Player MP3 Module

The DFMini Player module is a small musicplayer,lowcost and low power that has the purpose of reproducing sounds stored on a memory card.

Based on this, the module can be controlled via the standalone mode, that is, in this mode, there will only be the DFMini module, a battery to power, the speaker, buttons to control it and the SD Card with the songs.

Another way to control it is to use an Arduino or another control device. The Arduino, for example, will send commands through serial communication with the DFMini Player Module. The DFMini Player module is shown in Figure 1.

dfmini_YSxlLVh49X.jpgFigure 1 - DFMini Player Module.

To control it, it is important to use the basic standalone circuit. This circuit is shown in Figure 2.

circuitostandalone_4xsAxVYrKj.jpgFigure 2 - Standalone circuit of DFMini Player Module.

The two buttons shown in the circuit above are used to change the music tracks and control the volume of the sound.

The button connected to pin IO1 is used to go to the previous track and reduce the volume.

With a quick touch the system returns to the previous song, however, if you press the button for more than 1 second, the system will reduce the volume of the song.

The button connected to pin IO2 is used to go to the next track and increase the volume.

With a quick touch the system advances to the next song, however, if you press the button for more than 1 second, the system will increase the volume of the song.

In this standalone method, the songs must be saved on the memory card, as shown in Figure 3.

sdcard_0pGv39EGEQ.jpgFigure 3 - Song files in SD Card.

This way, each time the buttons are pressed, the system will play each song in ascending or descending order.

However, when using Arduino or another control device, we must modify the way of organizing the musical files on the SD Card.

Now, I'll explain how to control the DFMini Player using the Arduino through serial communication.

Controlling the DFMini Player with Arduino

In this step, the volume control, range control, equalization commands and other features will be sent by Arduino.

The Arduino must communicate via the serial with the DFMini Player and send the control commands. The electronic scheme of the control circuit is shown in Figure 4.

arduinomusic_vTmxulRDli.jpgFigure 4 - Electronic Schematic with Arduino.

First, we must assemble the circuit shown in the Figure below.

After assembling this circuit, you must add the songs on your memory card. In this step, the songs should be renamed as 01, 02, 03, for example.

You cannot leave the songs with their names, as there will be a problem when the Arduino sends the command to execute the specific track. Therefore, you must configure as shown below.

sdcardard_cFmxjS5ffi.jpgFigure 5 - Songs named by numbers.

After naming the files, write the following code on your Arduino.

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

//Inicia a serial por software nos pinos 10 e 11
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
char command;
int pausa = 0;

void setup()
//Comunicacao serial com o modulo
//Inicializa a serial do Arduino
//Verifica se o modulo esta respondendo...
Read more »