Introduction: How to Make a DIY Music Player?

About: Empowering Creation for Future Innovators; Our mission is to form a community with easy access to whether hardware, software and ideas that allow makers and younger generation to achieve their goals and realiz…

I always want to make a DIY music player, but I don’t know why I failed every time. So I searched information on line and I finally found a guide at other forum.


DFRduino UNO R3 (same as Arduino UNO Rev3)*1

IR Kit for Arduino*1

DFPlayer - A Mini MP3 Player For Arduino *1

Jumper Wires


Official statement:

Arduino can be directly used to supply power for this module, which will not cause any impact on Arduino.

If you use Arduino to supply power, be sure to add two 1K resistors on the serial-port communication port to eliminate the noise!

The circuit below has been constructed:

Step 1: Code


* name: DFPlayer_Mini_Mp3 * version: 1.0 * Author: Apple tec.<[email][/email]> * Date: 2015-07-16 * Description: * note: mp3 file must put into mp3 folder in your tf card */

#include #include #include

//定义对应16进制数值的常量名 #define POWER 0xFD00FF #define VOLUP 0xFD807F //VOL+ #define STOP 0xFD40BF //FUNC/STOP #define PREV 0xFD20DF #define PAUSE 0xFDA05F #define NEXT 0xFD609F #define DOWN 0xFD10EF #define VOLDOWN 0xFD906F //VOL- #define UP 0xFD50AF #define ZERO 0xFD30CF //0 #define EQ 0xFDB04F //EQ #define REPT 0xFD708F //ST/REPT #define ONE 0xFD08F7 //1 #define TWO 0xFD8877 //2 #define THREE 0xFD48B7 //3 #define FOUR 0xFD28D7 //4 #define FIVE 0xFDA857 //5 #define SIX 0xFD6897 //6 #define SEVEN 0xFD18E7 //7 #define EIGHT 0xFD9867 //8 #define NINE 0xFD58A7 //9

int recvPin = 2; boolean a = true; int i = 20; int z = 0; IRrecv recv(recvPin); decode_results res;

void setup() { Serial.begin(9600); recv.enableIRIn(); mp3_set_serial (Serial); mp3_set_volume (i); mp3_set_EQ (z); }

void loop() { if(recv.decode(&res)) { switch(res.value) {

case POWER: if (a == false) { a = !a; mp3_stop (); } break;

case PREV: if (a == true) { a = !a; } mp3_prev (); break;

case NEXT: if (a == true) { a = !a; } mp3_next (); break;

case PAUSE: if (a == true) { a = !a; mp3_play (); } else { a = !a; mp3_pause (); } break;

case VOLUP: if (i < 30) { i = i+1; mp3_set_volume (i); } break;

case VOLDOWN: if (i > 0) { i = i-1; mp3_set_volume (i); } break;

case EQ: if (z < 5) { z = z+1; } else { z = 0; } mp3_set_EQ (z); break;

case REPT : if (a == true) { a = !a; } mp3_random_play (); break;

case ONE: if (a == true) { a = !a; } mp3_play (1); break;

case TWO: if (a == true) { a = !a; } mp3_play (2); break;

case THREE: if (a == true) { a = !a; } mp3_play (3); break;

case FOUR: if (a == true) { a = !a; } mp3_play (4); break;

case FIVE: if (a == true) { a = !a; } mp3_play (5); break;

case SIX: if (a == true) { a = !a; } mp3_play (6); break;

case SEVEN: if (a == true) { a = !a; } mp3_play (7); break;

case EIGHT: if (a == true) { a = !a; } mp3_play (8); break;

case NINE: if (a == true) { a = !a; } mp3_play (9); break;

default: ; } recv.resume(); } }

Step 2: IR Remote Control Music Player

If everything goes well, you will get a music player controlled by IR remote control unit.

* Please carefully read the notes on use of DFPlayer Mini Module below!

* DFPlayer Mini can read files in MP3 & WAV format (the actual test indicates 320K super high quality music can be decoded), but audios with duration less than 1 second cannot be played.

* Be sure to place all music files in MP3 folder, and MP3 files shall be named with four digits, e.g., "0001.mp3", and then placed in MP3 folder. If Chinese or English name is required, English words shall be added at the rear of digits, e.g., "0001hello.mp3" or "0001后来.mp3". See the data manual for the details.

DFPlayer mini library files used in the code have been modified, and “all cycle” function is added.