Sing for the moment! The DFPlayer Mini is a small and low-cost MP3 module player with a simplified output directly to the speaker. The DFPlayer mini standalone can be used as a stand-alone module with an attached battery, speaker, and push buttons or used in combination with an Arduino UNO or any other with RX/TX capabilities.
This dfrobot mp3 player perfectly integrates the hard decoding module, which supports common audio formats such as MP3, WAV, and WMA. Besides, the dfplayer mini mp3 player module also supports TF card with FAT16, FAT32 file system. Through a simple serial port, you can play the designated music without any other tedious underlying operations.
MicroSD Cart Needs to be formatted to FAT32:
How to Format an SD Card to FAT32 on a Mac
Open Disk Utility.
Click your SD card in the External section.
Click Erase.
Rename the card if you want, and click on the Format drop down.
Click MS-DOS (FAT).
Click Erase. The SD card will start formatting as soon as you click Erase.
Sep 22, 2022
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
// Define the RX and TX pins for SoftwareSerial communication
#define RX_PIN 10
#define TX_PIN 11
SoftwareSerial mySerial(RX_PIN, TX_PIN); // Create a SoftwareSerial object
DFRobotDFPlayerMini myDFPlayer; // Create a DFPlayer Mini object
void setup() {
// Initialize the serial communication for debugging
Serial.begin(9600);
Serial.println();
Serial.println("DFPlayer Mini Test");
// Initialize SoftwareSerial communication with the DFPlayer Mini
mySerial.begin(9600);
// Initialize the DFPlayer Mini object
if (!myDFPlayer.begin(mySerial)) {
Serial.println("Unable to begin:");
Serial.println("1. Please recheck the connection!");
Serial.println("2. Please insert the SD card!");
while (true);
}
// Set the volume (0-30)
myDFPlayer.volume(30); // Set the volume to a value between 0 and 30
}
void loop() {
// Check if a command is received from the Serial Monitor
if (Serial.available()) {
char command = Serial.read();
if (command == '1') {
Serial.println("Playing track 001.mp3");
myDFPlayer.play(1);
}
if (command == '3') {
Serial.println("Playing track 003.mp3");
myDFPlayer.play(3);
}
if (command == '5') {
Serial.println("Playing track 005.mp3");
myDFPlayer.play(5);
}
if (command == '7') {
Serial.println("Playing track 007.mp3");
myDFPlayer.play(7);
}
if (command == '9') {
Serial.println("Playing track 009.mp3");
myDFPlayer.play(9);
}
}
}