### DFPlayerMini Initialization Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Demonstrates how to initialize the DFPlayerMini module using the begin() method. Ensure correct serial port setup for your specific Arduino board. ```cpp #include "Arduino.h" #include "DFRobotDFPlayerMini.h" #include "SoftwareSerial.h" // Use SoftwareSerial to communicate with DFPlayerMini // RX, TX pins SoftwareSerial mySoftwareSerial(10, 11); // RX, TX DFRobotDFPlayerMini myDFPlayer; void setup() { mySoftwareSerial.begin(9600); Serial.begin(115200); Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)")); // It is recommended to begin the DFPlayer module with a timeout // The default serial port is SoftwareSerial if (!myDFPlayer.begin(mySoftwareSerial)) { //Use this interface to set the serial port Serial.println(F("Unable to begin:")); Serial.println(F("1.Please recheck your connection!")); Serial.println(F("2.Please insert the SD card!")); while (true); } Serial.println(F("DFPlayer Mini online.")); } ``` -------------------------------- ### Minimal Working Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/quick-reference.md This is a basic example demonstrating how to initialize the DFPlayer Mini and play the first track. ```cpp #include "Arduino.h" #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); DFRobotDFPlayerMini myDFPlayer; void setup() { softSerial.begin(9600); Serial.begin(115200); if (!myDFPlayer.begin(softSerial)) { Serial.println("Init failed"); while(1); } myDFPlayer.volume(20); myDFPlayer.play(1); } void loop() { if (myDFPlayer.available()) { uint8_t type = myDFPlayer.readType(); uint16_t param = myDFPlayer.read(); if (type == DFPlayerPlayFinished) { myDFPlayer.next(); } } } ``` -------------------------------- ### DFRobotDFPlayerMini Complete Usage Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md A comprehensive example demonstrating the initialization, configuration, and basic operation of the DFRobotDFPlayerMini, including playback control and event handling. ```cpp #include "Arduino.h" #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); // RX, TX DFRobotDFPlayerMini myDFPlayer; void setup() { softSerial.begin(9600); Serial.begin(115200); // Initialize DFPlayer if (!myDFPlayer.begin(softSerial, true, true)) { Serial.println("DFPlayer init failed"); while(true); } // Configure settings myDFPlayer.setTimeOut(500); myDFPlayer.volume(15); myDFPlayer.EQ(DFPLAYER_EQ_NORMAL); myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD); // Start playing myDFPlayer.play(1); } void loop() { // Handle incoming messages every loop iteration if (myDFPlayer.available()) { uint8_t type = myDFPlayer.readType(); uint16_t param = myDFPlayer.read(); if (type == DFPlayerPlayFinished) { Serial.print("File "); Serial.print(param); Serial.println(" finished"); myDFPlayer.next(); } else if (type == DFPlayerError) { Serial.print("Error: "); Serial.println(param); } } // Every 5 seconds, check status static unsigned long timer = millis(); if (millis() - timer > 5000) { timer = millis(); int vol = myDFPlayer.readVolume(); if (vol >= 0) { Serial.print("Current volume: "); Serial.println(vol); } } } ``` -------------------------------- ### DFPlayerMini Status Checking Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Provides examples of how to check the status of the DFPlayerMini module, such as checking if data is available or reading the current playback state. ```cpp // Check if there is any available data to read if (myDFPlayer.available()) { Serial.print(myDFPlayer.readType()); Serial.print(": "); Serial.println(myDFPlayer.read()); } // Example of reading device status (specific method not shown, but conceptually represented) // Serial.println(myDFPlayer.readState()); ``` -------------------------------- ### DFPlayerMini Example: Handling Card Insertion and Playback Finish Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md A conceptual example demonstrating how to handle events like SD card insertion and the completion of a track playback using the DFPlayerMini's feedback mechanism. ```cpp void loop() { if (myDFPlayer.available()) { Serial.print(myDFPlayer.readType()); Serial.print(": "); Serial.println(myDFPlayer.read()); // Example: Handle card insertion if (myDFPlayer.readType() == DFPlayerCardInserted) { Serial.println("SD Card inserted."); // Optionally start playback or perform other actions myDFPlayer.play(1, 0); } // Example: Handle playback finished if (myDFPlayer.readType() == DFPlayerPlayFinished) { Serial.println("Playback finished."); // Optionally play next track or stop // myDFPlayer.next(); } // Example: Handle errors if (myDFPlayer.readType() == DFPlayerError) { Serial.print("Error: "); Serial.println(myDFPlayer.readError()); } } } ``` -------------------------------- ### Debug Output Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Example of the debug output seen when the `_DEBUG` macro is enabled, showing sent and received packets. ```text sending: 7E FF 06 03 01 00 05 FE F1 EF received: 7E FF 06 41 00 00 01 FE FE EF ``` -------------------------------- ### DFPlayerMini Volume Control Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Demonstrates how to set the volume and adjust it using volumeUp() and volumeDown() methods. Volume is on a scale of 0 to 30. ```cpp // Set volume to level 20 myDFPlayer.volume(20); // Increase volume by one level myDFPlayer.volumeUp(); // Decrease volume by one level myDFPlayer.volumeDown(); ``` -------------------------------- ### Complete DFRobot Dfplayer Mini Error and Event Handling Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/errors.md A comprehensive example demonstrating how to handle various messages, including timeouts, errors, and SD card events, from the DFRobot Dfplayer Mini. It also includes a detailed `handleError` function for specific error codes. ```cpp #include "Arduino.h" #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); DFRobotDFPlayerMini myDFPlayer; void handleMessage(uint8_t type, uint16_t param) { switch (type) { case TimeOut: Serial.println("TIMEOUT: Device not responding"); break; case WrongStack: Serial.println("ERROR: Invalid protocol message"); break; case DFPlayerCardInserted: Serial.println("EVENT: SD card inserted"); break; case DFPlayerCardRemoved: Serial.println("EVENT: SD card removed"); myDFPlayer.stop(); break; case DFPlayerCardOnline: Serial.println("EVENT: SD card online"); break; case DFPlayerPlayFinished: Serial.print("EVENT: File "); Serial.print(param); Serial.println(" finished"); myDFPlayer.next(); break; case DFPlayerError: handleError(param); break; case DFPlayerFeedBack: Serial.print("FEEDBACK: "); Serial.println(param); break; default: break; } } void handleError(uint16_t errorCode) { Serial.print("ERROR CODE: "); Serial.print(errorCode); Serial.print(" - "); switch (errorCode) { case Busy: Serial.println("Device busy"); break; case Sleeping: Serial.println("Device sleeping"); break; case SerialWrongStack: Serial.println("Serial protocol error"); break; case CheckSumNotMatch: Serial.println("Checksum mismatch"); break; case FileIndexOut: Serial.println("File index out of bounds"); break; case FileMismatch: Serial.println("File not found"); break; case Advertise: Serial.println("In advertisement mode"); break; default: Serial.println("Unknown error"); } } void setup() { softSerial.begin(9600); Serial.begin(115200); if (!myDFPlayer.begin(softSerial, true, true)) { Serial.println("Failed to initialize DFPlayer"); while(true) { delay(100); } } myDFPlayer.setTimeOut(500); myDFPlayer.volume(15); myDFPlayer.play(1); } void loop() { // Always check for messages in main loop if (myDFPlayer.available()) { handleMessage(myDFPlayer.readType(), myDFPlayer.read()); } } ``` -------------------------------- ### DFPlayerMini Playback Control Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Shows basic playback control functions like playing a specific file, playing the next track, and pausing. Assumes files are numbered sequentially on the SD card. ```cpp // Play the first MP3 file on the SD card myDFPlayer.play(1, 0); // Play the next MP3 file myDFPlayer.next(); // Pause playback myDFPlayer.pause(); // Resume playback myDFPlayer.start(); // Stop playback myDFPlayer.stop(); ``` -------------------------------- ### Arduino Uno/Leonardo SoftwareSerial Setup Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Configure SoftwareSerial for communication with the DFPlayer Mini on Arduino Uno/Leonardo. Ensure the baud rate is set to 9600. ```cpp #include SoftwareSerial softSerial(/*RX=*/4, /*TX=*/5); void setup() { softSerial.begin(9600); // Must be 9600 myDFPlayer.begin(softSerial, true, true); } ``` -------------------------------- ### SD Card File Path Examples Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Shows how specific file paths on the SD card map to function calls for playback. This helps in understanding how to reference audio files using folder and file numbers. ```text SD:/01/001.mp3 <- playFolder(1, 1) SD:/01/002.mp3 <- playFolder(1, 2) SD:/15/004.mp3 <- playFolder(15, 4) SD:/MP3/0004.mp3 <- playMp3Folder(4) SD:/ADVERT/0003.mp3 <- advertise(3) ``` -------------------------------- ### ESP8266 SoftwareSerial Setup Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Configure SoftwareSerial for communication with the DFPlayer Mini on ESP8266. Ensure the baud rate is 9600 and the format is SERIAL_8N1. ```cpp void setup() { softSerial.begin(9600, SERIAL_8N1, /*RX=*/D3, /*TX=*/D2); myDFPlayer.begin(softSerial, true, true); } ``` -------------------------------- ### DFPlayer Mini Get Folder Count Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the total number of folders on the storage device. This command does not require any specific parameters. ```text Code: 0x4F Method: readFolderCounts() Parameter: 0x0000 ``` -------------------------------- ### DFPlayerMini Checksum Calculation Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Demonstrates the algorithm for calculating the checksum, which is essential for ensuring the integrity of serial communication packets sent to the DFPlayerMini. ```plaintext Checksum = (0x100 - (Byte3 + Byte4 + Byte5 + Byte6 + Byte7 + Byte8)) & 0xFF; // Example: Command 0x0D (Play), Params 0x00, 0x01, 0x00, 0x00 // Checksum = (0x100 - (0x0D + 0x00 + 0x01 + 0x00 + 0x00 + 0x00)) & 0xFF // Checksum = (0x100 - 0x0E) & 0xFF = 0xF2 ``` -------------------------------- ### Full DFPlayer Mini Initialization and Configuration Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Initializes the DFPlayer Mini with specified serial communication, configures communication timeout, audio output, volume, equalizer, amplifier, DAC, and playback mode. Handles device messages and includes an example for changing volume on button press. ```cpp #include "Arduino.h" #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); DFRobotDFPlayerMini myDFPlayer; void setup() { // Initialize serial communication softSerial.begin(9600); Serial.begin(115200); // Initialize DFPlayer with full initialization and acknowledgement if (!myDFPlayer.begin(softSerial, /*isACK=*/true, /*doReset=*/true)) { Serial.println("DFPlayer initialization failed"); while(true) { delay(100); } } Serial.println("DFPlayer initialized successfully"); // Configure communication timeout myDFPlayer.setTimeOut(500); // 500ms timeout // Configure audio output device myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD); // Use SD card delay(200); // Allow device to switch // Configure volume myDFPlayer.volume(20); // Set to 20 (loud but not maximum) // Configure equalizer myDFPlayer.EQ(DFPLAYER_EQ_NORMAL); // Neutral sound // Configure output amplifier myDFPlayer.outputSetting(true, 15); // Enable with medium gain // Enable DAC for analog output myDFPlayer.enableDAC(); // Configure playback mode myDFPlayer.enableLoop(); // Loop current file when finished myDFPlayer.disableLoopAll(); // Don't loop all files // Start playing myDFPlayer.play(1); } void loop() { // Handle device messages if (myDFPlayer.available()) { uint8_t type = myDFPlayer.readType(); uint16_t param = myDFPlayer.read(); if (type == DFPlayerPlayFinished) { Serial.print("File "); Serial.print(param); Serial.println(" finished"); } else if (type == DFPlayerError) { Serial.print("Error: "); Serial.println(param); } } // Example: Change volume on button press // (Assuming button on pin 2) if (digitalRead(2) == LOW) { static unsigned long lastPress = 0; if (millis() - lastPress > 500) { // Debounce lastPress = millis(); int currentVol = myDFPlayer.readVolume(); if (myDFPlayer.waitAvailable()) { if (myDFPlayer.readType() == DFPlayerFeedBack) { currentVol = myDFPlayer.read(); if (currentVol < 30) { myDFPlayer.volume(currentVol + 1); } } } } } } ``` -------------------------------- ### SD Card File Structure Example Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Illustrates the recommended folder and file structure for MP3 files on the SD card. Folders are numbered 1-99, with special folders for advertisements and MP3s. Files follow a naming convention like 001.mp3. ```text SD Card Root ├── /01 │ ├── 001.mp3 │ ├── 002.mp3 │ └── ... ├── /02 │ ├── 001.mp3 │ └── ... ├── /MP3 │ ├── 0001.mp3 │ ├── 0002.mp3 │ └── ... ├── /ADVERT │ ├── 0001.mp3 │ └── ... └── (Other folders /03 through /99) ``` -------------------------------- ### DFRobotDFPlayerMini Public Methods Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md This section details the public methods available for controlling the DFRobotDFPlayerMini module. Each method includes its signature, parameters, return values, and usage examples. ```APIDOC ## Initialization ### `begin()` **Description**: Initializes the DFPlayerMini module. ### `setTimeOut(int time)` **Description**: Sets the timeout duration for waiting for available data. ### `waitAvailable()` **Description**: Waits until the DFPlayerMini module is available. ## Playback Control ### `play(int fileNumber)` **Description**: Plays a specific audio file by its number. ### `next()` **Description**: Plays the next audio file in the sequence. ### `previous()` **Description**: Plays the previous audio file in the sequence. ### `pause()` **Description**: Pauses the current playback. ### `start()` **Description**: Resumes playback if paused. ### `stop()` **Description**: Stops the current playback. ### `loop(int fileNumber)` **Description**: Sets a specific audio file to loop. ## Volume Control ### `volume(int volumeLevel)` **Description**: Sets the playback volume to a specific level. ### `volumeUp()` **Description**: Increases the playback volume. ### `volumeDown()` **Description**: Decreases the playback volume. ## Audio Settings ### `EQ(int eqPreset)` **Description**: Sets the equalizer preset for audio output. ### `outputDevice(int device)` **Description**: Selects the audio output device. ### `outputSetting(int setting)` **Description**: Configures audio output settings. ### `enableDAC()` **Description**: Enables the Digital-to-Analog Converter (DAC). ### `disableDAC()` **Description**: Disables the Digital-to-Analog Converter (DAC). ## Loop Modes ### `enableLoop()` **Description**: Enables looping for the current track. ### `disableLoop()` **Description**: Disables looping for the current track. ### `enableLoopAll()` **Description**: Enables looping for all tracks in the current folder/playlist. ### `disableLoopAll()` **Description**: Disables looping for all tracks. ## Device Control ### `sleep()` **Description**: Puts the DFPlayerMini module into sleep mode. ### `reset()` **Description**: Resets the DFPlayerMini module to its default state. ## Status Reading *(Note: 10 methods are available for querying device state, specific method names are not listed in the source but are implied.)* ## Message Handling ### `available()` **Description**: Checks if there is any data available from the DFPlayerMini. ### `readType()` **Description**: Reads the type of the next available message. ### `read()` **Description**: Reads the next available byte from the DFPlayerMini. ### `readCommand()` **Description**: Reads and processes the next command from the DFPlayerMini. ``` -------------------------------- ### ESP32 Hardware Serial Setup Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Configure hardware serial for communication with the DFPlayer Mini on ESP32. The baud rate must be 9600 and the format is SERIAL_8N1. ```cpp void setup() { Serial1.begin(9600, SERIAL_8N1, /*RX=*/D3, /*TX=*/D2); myDFPlayer.begin(Serial1, true, true); } ``` -------------------------------- ### DFPlayer Mini Get File Count on SD Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the total number of files stored on the SD card. This command does not require any specific parameters. ```text Code: 0x48 Method: readFileCounts(DEVICE_SD) Parameter: 0x0000 ``` -------------------------------- ### Set Volume Command Packet Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Example of a packet to set the playback volume. The parameter represents the desired volume level. ```hex 7E FF 06 06 01 00 14 FE E0 EF ``` -------------------------------- ### Arduino Mega Hardware Serial 1 Setup Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Configure hardware serial port 1 for communication with the DFPlayer Mini on Arduino Mega. The baud rate must be 9600. ```cpp void setup() { Serial1.begin(9600); // Hardware serial port 1 myDFPlayer.begin(Serial1, true, true); } ``` -------------------------------- ### readFileCounts() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Gets the total number of files present on the SD card. This method is part of the Project: /dfrobot/dfrobotdfplayermini. ```APIDOC ## readFileCounts() ### Description Get the total number of files on the SD card. ### Method int ### Parameters None ### Return int — Total file count, or -1 on error ### Example ```cpp int totalFiles = myDFPlayer.readFileCounts(); ``` ``` -------------------------------- ### Get Folder Count Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Retrieves the total number of folders available on the device. Returns -1 if an error occurs. ```cpp int readFolderCounts() ``` ```cpp int numFolders = myDFPlayer.readFolderCounts(); ``` -------------------------------- ### Play File Command Packet Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Example of a packet to command the DFPlayer Mini to play a specific file. The checksum is calculated based on the preceding bytes. ```hex 7E FF 06 03 01 00 05 FE F1 EF ``` -------------------------------- ### readFileCounts(uint8_t device) Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Gets the file count from a specific device (e.g., USB drive, SD card, flash memory). This method is part of the Project: /dfrobot/dfrobotdfplayermini. ```APIDOC ## readFileCounts(uint8_t device) ### Description Get the file count from a specific device. ### Method int ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **device** (uint8_t) - Required - Device identifier (DFPLAYER_DEVICE_U_DISK, DFPLAYER_DEVICE_SD, DFPLAYER_DEVICE_FLASH) ### Return int — File count on specified device, or -1 on error ### Example ```cpp int usbFiles = myDFPlayer.readFileCounts(DFPLAYER_DEVICE_U_DISK); int sdFiles = myDFPlayer.readFileCounts(DFPLAYER_DEVICE_SD); ``` ``` -------------------------------- ### DFPlayer Mini Initialization Parameters Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md The begin() method initializes the DFPlayer Mini. It accepts a Stream object for communication, an optional boolean to enable device acknowledgement, and another boolean to perform a device reset. ```cpp bool begin(Stream &stream, bool isACK = true, bool doReset = true) ``` -------------------------------- ### Get Total File Count on SD Card Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Query the device to get the total number of files stored on the SD card. Returns -1 if an error occurs. ```cpp int totalFiles = myDFPlayer.readFileCounts(); ``` -------------------------------- ### DFPlayer Mini Get File Count in Folder Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the number of files within a specific folder. The folder number is provided as a 16-bit parameter. ```text Code: 0x4E Method: readFileCountsInFolder(folder) Parameter: folderNum ``` -------------------------------- ### Initialization Configuration Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Configure the DFPlayer Mini during initialization using the begin() method. This method allows setting up the communication stream and enabling/disabling acknowledgement and reset functionalities. ```APIDOC ## begin() ### Description Initializes the DFPlayer Mini with specified communication stream and configuration options. ### Method bool begin(Stream &stream, bool isACK = true, bool doReset = true) ### Parameters #### Path Parameters - **stream** (Stream&) - Required - Serial stream for communication (Serial, Serial1, SoftwareSerial, etc.). #### Query Parameters - **isACK** (bool) - Optional - Enable device acknowledgement mode. When true, device confirms receipt of each command. When false, commands execute without confirmation. Default: true. - **doReset** (bool) - Optional - Reset device during initialization. When true, performs full reset which takes 2-5 seconds. When false, assumes device is already in good state. Default: true. ### Return `bool` - Returns true if device detected as online (card or USB device found), false otherwise. ``` -------------------------------- ### DFPlayer Mini Get File Count on USB Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the total number of files stored on the USB drive. This command does not require any specific parameters. ```text Code: 0x47 Method: readFileCounts(DEVICE_U_DISK) Parameter: 0x0000 ``` -------------------------------- ### Initialize DFRobotDFPlayerMini Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/quick-reference.md Include necessary libraries and initialize the DFPlayerMini module using SoftwareSerial. Ensure the serial communication begins at 9600 baud. ```cpp #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); // RX, TX DFRobotDFPlayerMini myDFPlayer; void setup() { softSerial.begin(9600); if (!myDFPlayer.begin(softSerial)) { // Initialization failed } } ``` -------------------------------- ### Basic Arduino Initialization and Playback Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/README.md Initializes the DFPlayer Mini using SoftwareSerial and plays the first file. Handles initialization failures by halting execution. Checks for playback completion and plays the next track. ```cpp #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); // RX, TX DFRobotDFPlayerMini myDFPlayer; void setup() { softSerial.begin(9600); if (!myDFPlayer.begin(softSerial)) { while(1); // Initialization failed } myDFPlayer.volume(20); myDFPlayer.play(1); } void loop() { if (myDFPlayer.available()) { if (myDFPlayer.readType() == DFPlayerPlayFinished) { myDFPlayer.next(); } } } ``` -------------------------------- ### DFPlayer Mini Get Current File Number on SD Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the number of the currently playing file on the SD card. This command does not require any specific parameters. ```text Code: 0x4C Method: readCurrentFileNumber(DEVICE_SD) Parameter: 0x0000 ``` -------------------------------- ### DFPlayer Mini Get Current File Number on USB Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the number of the currently playing file on the USB drive. This command does not require any specific parameters. ```text Code: 0x4B Method: readCurrentFileNumber(DEVICE_U_DISK) Parameter: 0x0000 ``` -------------------------------- ### DFPlayer Mini Get File Count on Flash Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the total number of files stored in the internal flash memory. This command does not require any specific parameters. ```text Code: 0x49 Method: readFileCounts(DEVICE_FLASH) Parameter: 0x0000 ``` -------------------------------- ### DFPlayer Mini Get Current File Number on Flash Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to get the number of the currently playing file in the internal flash memory. This command does not require any specific parameters. ```text Code: 0x4D Method: readCurrentFileNumber(DEVICE_FLASH) Parameter: 0x0000 ``` -------------------------------- ### DFPlayerMini Loop Mode Configuration Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Shows how to configure loop modes for single files or all files. Use enableLoop() for a specific file and enableLoopAll() for all files. ```cpp // Enable loop for the current file myDFPlayer.enableLoop(1); // Disable loop for the current file myDFPlayer.disableLoop(); // Enable loop for all files myDFPlayer.enableLoopAll(); // Disable loop for all files myDFPlayer.disableLoopAll(); ``` -------------------------------- ### Manual Packet Construction for Play Command Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Demonstrates how to manually construct a play command packet. This is for low-level understanding; the library typically handles this automatically. ```cpp // Construct a play command manually uint8_t packet[10] = { 0x7E, // Header 0xFF, // Version 0x06, // Length 0x03, // Command (play) 0x01, // ACK flag 0x00, 0x05, // Parameter (file 5) 0xFE, 0xF1, // Checksum for this example 0xEF // End marker }; // Send packet Serial1.write(packet, 10); ``` -------------------------------- ### outputSetting() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Configures the output amplifier settings, including enabling/disabling and setting the gain level. ```APIDOC ## outputSetting(enable, gain) ### Description Configure output amplifier settings. ### Method ```cpp void outputSetting(bool enable, uint8_t gain) ``` ### Parameters #### Path Parameters - **enable** (bool) - Required - Enable/disable output - **gain** (uint8_t) - Required - Gain level (0-31) ### Request Example ```cpp myDFPlayer.outputSetting(true, 15); // Enable output with gain 15 ``` ``` -------------------------------- ### readCurrentFileNumber() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Gets the file number that is currently playing from the SD card. This method is part of the Project: /dfrobot/dfrobotdfplayermini. ```APIDOC ## readCurrentFileNumber() ### Description Get the file number currently playing on the SD card. ### Method int ### Parameters None ### Return int — Currently playing file number, or -1 on error ### Example ```cpp int current = myDFPlayer.readCurrentFileNumber(); ``` ``` -------------------------------- ### DFPlayer Mini Enable/Disable Loop All Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to enable or disable looping of all files. Use 0x0001 to enable and 0x0000 to disable. ```text Code: 0x11 Method: enableLoopAll() / disableLoopAll() Parameter: 0x0001 / 0x0000 ``` -------------------------------- ### Pause Playback Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Pauses the currently playing audio file. Playback can be resumed using the `start()` method. ```cpp myDFPlayer.pause(); ``` -------------------------------- ### Play Finished Response Packet Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Example of a device response indicating that a file has finished playing. This response does not request an acknowledgement. ```hex 7E FF 06 3C 00 00 05 FE BB EF ``` -------------------------------- ### Enable All Files Loop Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Enables continuous looping of all audio files on the storage device. ```cpp void enableLoopAll() ``` ```cpp myDFPlayer.enableLoopAll(); ``` -------------------------------- ### DFPlayerMini EQ and Output Device Configuration Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Illustrates how to set the equalizer preset and select the audio output device. Supported EQ presets include NORMAL, POP, ROCK, JAZZ, CLASSIC, and BASS. ```cpp // Set Equalizer to Rock mode myDFPlayer.EQ(ROCK); // Select AUX as the audio output device myDFPlayer.outputDevice(AUX); // Enable DAC for audio output myDFPlayer.enableDAC(); ``` -------------------------------- ### Volume Feedback Response Packet Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Example of a device response providing the current volume level. The command code indicates feedback. ```hex 7E FF 06 42 00 00 14 FE A5 EF ``` -------------------------------- ### Query Current Volume and Handle Feedback Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/quick-reference.md Demonstrates how to read the current volume and process feedback from the DFPlayer Mini, useful for interactive applications. ```cpp myDFPlayer.readVolume(); if (myDFPlayer.waitAvailable()) { if (myDFPlayer.readType() == DFPlayerFeedBack) { int vol = myDFPlayer.read(); Serial.println(vol); } } ``` -------------------------------- ### Get File Count in Folder Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Retrieves the number of files within a specific folder on the device. Returns -1 if an error occurs. ```cpp int readFileCountsInFolder(int folderNumber) ``` ```cpp int filesInFolder = myDFPlayer.readFileCountsInFolder(3); ``` -------------------------------- ### DFPlayer Mini Configure Output Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to configure the audio output settings, including enable status and gain. The parameter is a 16-bit value where the upper 8 bits are for enable and the lower 8 bits are for gain. ```text Code: 0x10 Method: outputSetting(en, gain) Parameter: (en<<8)|gain ``` -------------------------------- ### Get Current File Number Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Retrieves the number of the file currently playing on a specified device. Returns -1 if an error occurs. ```cpp int readCurrentFileNumber(uint8_t device) ``` ```cpp int current = myDFPlayer.readCurrentFileNumber(DFPLAYER_DEVICE_USB); ``` -------------------------------- ### Read Current Playing File Number Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Get the file number that is currently playing from the SD card. Returns -1 if there is an error. ```cpp int current = myDFPlayer.readCurrentFileNumber(); ``` -------------------------------- ### Read Current Volume Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Get the current volume level of the device. The volume ranges from 0 to 30. Returns -1 on error. ```cpp int currentVol = myDFPlayer.readVolume(); ``` -------------------------------- ### DFRobotDFPlayerMini Class Initialization Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Initializes communication with the DFPlayer Mini device. This method sets up the serial communication and can optionally enable acknowledgements and reset the device. ```APIDOC ## begin() ### Description Initialize communication with the DFPlayer Mini device. ### Method bool begin(Stream &stream, bool isACK = true, bool doReset = true) ### Parameters #### Path Parameters - stream (Stream&) - Required - Serial stream object for communication (e.g., Serial1, SoftwareSerial) #### Query Parameters - isACK (bool) - Optional - Enable acknowledgement mode (device confirms receipt of commands) - doReset (bool) - Optional - Reset the device during initialization ### Response #### Success Response (true) - Returns `true` if initialization successful (device detected as online). #### Failure Response (false) - Returns `false` otherwise. ### Request Example ```cpp #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); // RX, TX pins DFRobotDFPlayerMini myDFPlayer; void setup() { softSerial.begin(9600); Serial.begin(115200); if (!myDFPlayer.begin(softSerial, true, true)) { Serial.println("DFPlayer failed to initialize"); while(true); } Serial.println("DFPlayer initialized successfully"); } ``` ``` -------------------------------- ### Read Message Parameter Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Get the parameter value associated with the last received message. The meaning of this value depends on the message type. ```cpp uint16_t param = myDFPlayer.read(); ``` -------------------------------- ### Initialize DFPlayer Mini Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Initializes communication with the DFPlayer Mini module. Ensure the correct Stream object and optional parameters for acknowledgement and reset are provided. Returns true if the device is detected online. ```cpp #include "DFRobotDFPlayerMini.h" #include SoftwareSerial softSerial(4, 5); // RX, TX pins DFRobotDFPlayerMini myDFPlayer; void setup() { softSerial.begin(9600); Serial.begin(115200); if (!myDFPlayer.begin(softSerial, true, true)) { Serial.println("DFPlayer failed to initialize"); while(true); } Serial.println("DFPlayer initialized successfully"); } ``` -------------------------------- ### Waiting for Command Completion with waitAvailable Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Shows how to ensure a command has completed before sending the next one by using `waitAvailable()`. This is crucial for time-critical operations. ```cpp myDFPlayer.play(1); myDFPlayer.waitAvailable(); // Wait for ACK myDFPlayer.volume(20); ``` -------------------------------- ### DFPlayerMini Sleep and Reset Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/INDEX.md Demonstrates how to put the DFPlayerMini module into sleep mode and reset it. Sleep mode conserves power, while reset restarts the module. ```cpp // Put the DFPlayer into sleep mode myDFPlayer.sleep(); // Reset the DFPlayer module myDFPlayer.reset(); ``` -------------------------------- ### Configure Loop Modes Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/quick-reference.md Enable or disable looping for single files or all files. Use `enableLoop()` for the current file and `enableLoopAll()` for all files in the playlist. ```cpp // Single file looping myDFPlayer.enableLoop(); // Loop current file myDFPlayer.disableLoop(); // Disable loop // All files looping myDFPlayer.enableLoopAll(); // Loop all files myDFPlayer.disableLoopAll(); // Disable loop all ``` -------------------------------- ### Read Current Playback State Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Query the device to get its current playback state. Returns -1 if there's an error reading the state. ```cpp int state = myDFPlayer.readState(); if (state >= 0) { Serial.println(state); } else { Serial.println("Error reading state"); } ``` -------------------------------- ### Correct Sequential Serial Communication Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Demonstrates the correct way to send sequential commands to the DFPlayer Mini. Each command is sent after the previous one has completed. ```cpp // CORRECT - sequential transmission myDFPlayer.play(1); delay(100); myDFPlayer.volume(20); ``` -------------------------------- ### DFPlayer Mini Play Next File Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to play the next file in the current folder. This command does not require any specific parameters. ```text Code: 0x01 Method: next() Parameter: 0x0000 ``` -------------------------------- ### DFPlayer Mini Play MP3 from Root Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to play a specific MP3 file from the root directory of the storage device. The file number is provided as a 16-bit parameter. ```text Code: 0x12 Method: playMp3Folder(file) Parameter: file ``` -------------------------------- ### DFPlayer Mini Play All Random Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to play all files on the storage device in a random order. This command does not require any specific parameters. ```text Code: 0x18 Method: randomAll() Parameter: 0x0000 ``` -------------------------------- ### outputDevice() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Switches the audio output device or selects an input source. ```APIDOC ## outputDevice(device) ### Description Switch the output device or input source. ### Method ```cpp void outputDevice(uint8_t device) ``` ### Parameters #### Path Parameters - **device** (uint8_t) - Required - Device/source identifier (see constants) ### Request Example ```cpp myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD); // Use SD card ``` ### Valid Device Values - `DFPLAYER_DEVICE_U_DISK` (1) — USB disk - `DFPLAYER_DEVICE_SD` (2) — SD card - `DFPLAYER_DEVICE_AUX` (3) — Auxiliary input - `DFPLAYER_DEVICE_SLEEP` (4) — Sleep mode - `DFPLAYER_DEVICE_FLASH` (5) — Internal flash ``` -------------------------------- ### DFplayer Mini Reliable Operation Configuration Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/configuration.md Configures the Dfplayer Mini for reliable operation with a longer timeout and delays between operations. This setup is suitable when stability is prioritized over speed. ```cpp void setup() { softSerial.begin(9600); // Conservative configuration for reliability myDFPlayer.begin(softSerial, true, true); myDFPlayer.setTimeOut(2000); // Longer timeout // Delays between operations myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD); delay(500); // Extra settling time } void loop() { if (myDFPlayer.available()) { // Handle messages } delay(10); // Prevent overwhelming device } ``` -------------------------------- ### Get File Count from Specific Device Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Retrieve the number of files stored on a specified device (U disk, SD card, or flash memory). Returns -1 on error. ```cpp int usbFiles = myDFPlayer.readFileCounts(DFPLAYER_DEVICE_U_DISK); int sdFiles = myDFPlayer.readFileCounts(DFPLAYER_DEVICE_SD); ``` -------------------------------- ### Configure DFPlayer Timeouts Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/errors.md Initializes the DFPlayer and sets a communication timeout. This helps prevent the system from hanging indefinitely if the DFPlayer does not respond. ```cpp void setup() { if (!myDFPlayer.begin(FPSerial, true, true)) { Serial.println("Init failed"); while(true); } myDFPlayer.setTimeOut(2000); // 2 second timeout } ``` -------------------------------- ### advertise() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Plays an advertisement audio file. This function interrupts the current playback and resumes it automatically after the advertisement finishes. ```APIDOC ## advertise(fileNumber) ### Description Play an advertisement file that interrupts current playback and resumes afterward. ### Method ```cpp void advertise(int fileNumber) ``` ### Parameters #### Path Parameters - **fileNumber** (int) - Required - File number in ADVERT folder (range: 0-65535) ### Request Example ```cpp myDFPlayer.advertise(3); // Play SD:/ADVERT/0003.mp3 as advertisement ``` ``` -------------------------------- ### DFPlayer Mini Enable/Disable Single Loop Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to enable or disable looping of a single file. Use 0x0000 to enable and 0x0001 to disable. ```text Code: 0x19 Method: enableLoop() / disableLoop() Parameter: 0x0000 / 0x0001 ``` -------------------------------- ### DFPlayer Mini Play Previous File Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to play the previous file in the current folder. This command does not require any specific parameters. ```text Code: 0x02 Method: previous() Parameter: 0x0000 ``` -------------------------------- ### DFPlayer Mini Query EQ Setting Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to query the current equalizer setting of the DFPlayer Mini. This command does not require any specific parameters. ```text Code: 0x44 Method: readEQ() Parameter: 0x0000 ``` -------------------------------- ### DFPlayer Mini Play File in Folder Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to play a specific file from a specific folder. The parameter is a 16-bit value combining folder and file numbers. ```text Code: 0x0F Method: playFolder(fold, file) Parameter: (fold<<8)|file ``` -------------------------------- ### enableLoop() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Enables single file looping mode, causing the current audio file to repeat continuously. ```APIDOC ## enableLoop() ### Description Enable single file looping mode. ### Method ```cpp void enableLoop() ``` ### Request Example ```cpp myDFPlayer.enableLoop(); ``` ``` -------------------------------- ### Enable Single File Loop Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Enables a mode where the currently playing file will loop continuously. ```cpp void enableLoop() ``` ```cpp myDFPlayer.enableLoop(); ``` -------------------------------- ### enableLoopAll() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Enables continuous looping of all audio files in the current playback queue or folder. ```APIDOC ## enableLoopAll() ### Description Enable continuous looping of all files. ### Method ```cpp void enableLoopAll() ``` ### Request Example ```cpp myDFPlayer.enableLoopAll(); ``` ``` -------------------------------- ### Configure Audio Settings Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/quick-reference.md Set the equalizer and output device for the DFPlayerMini. The equalizer has presets like Normal, Pop, Rock, Jazz, Classic, and Bass. The output device can be USB, SD card, Auxiliary, Sleep mode, or internal Flash. ```cpp // Equalizer myDFPlayer.EQ(DFPLAYER_EQ_NORMAL); // 0=Normal, 1=Pop, 2=Rock, 3=Jazz, 4=Classic, 5=Bass // Output device myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD); // 1=USB, 2=SD, 3=AUX, 4=Sleep, 5=Flash // Output settings myDFPlayer.outputSetting(true, 15); // (enable, gain 0-31) myDFPlayer.enableDAC(); myDFPlayer.disableDAC(); ``` -------------------------------- ### Reset Device to Factory Defaults Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Call this method to reset the device to its original factory settings. ```cpp myDFPlayer.reset(); ``` -------------------------------- ### randomAll() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Plays all audio files stored on the device in a random playback order. ```APIDOC ## randomAll() ### Description Play all files in random order. ### Method ```cpp void randomAll() ``` ### Request Example ```cpp myDFPlayer.randomAll(); ``` ``` -------------------------------- ### Play Next File Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Advances playback to the next file in the current folder. This method is used for sequential playback. ```cpp myDFPlayer.next(); ``` -------------------------------- ### DFPlayer Mini Loop Folder Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to loop all files within a specified folder. The folder number is provided as a 16-bit parameter. ```text Code: 0x17 Method: loopFolder(folderNum) Parameter: folderNum ``` -------------------------------- ### DFPlayer Mini Resume Playback Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to resume playback from a paused state. This command does not require any specific parameters. ```text Code: 0x0D Method: start() Parameter: 0x0000 ``` -------------------------------- ### playMp3Folder() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Plays an audio file located in the dedicated /MP3 folder on the storage device. ```APIDOC ## playMp3Folder(fileNumber) ### Description Play a file from the /MP3 folder on the device. ### Method ```cpp void playMp3Folder(int fileNumber) ``` ### Parameters #### Path Parameters - **fileNumber** (int) - Required - File number within MP3 folder (range: 0-65535) ### Request Example ```cpp myDFPlayer.playMp3Folder(4); // Play SD:/MP3/0004.mp3 ``` ``` -------------------------------- ### Play Previous File Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Reverts playback to the previous file in the current folder. Useful for navigating backward through audio files. ```cpp myDFPlayer.previous(); ``` -------------------------------- ### Loop Folder Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Sets the player to loop all audio files within a specified folder. Folder numbers range from 1 to 99. ```cpp myDFPlayer.loopFolder(3); // Loop all files in folder 3 ``` -------------------------------- ### volume() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Sets the playback volume level for the Dfplayer Mini. ```APIDOC ## volume(volume) ### Description Set the playback volume. ### Method ```cpp void volume(uint8_t volume) ``` ### Parameters #### Path Parameters - **volume** (uint8_t) - Required - Volume level (0-30, where 0 is silent) ### Request Example ```cpp myDFPlayer.volume(20); // Set volume to 20 ``` ``` -------------------------------- ### reset() Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/api-reference.md Resets the device to its factory default settings. This method is part of the Project: /dfrobot/dfrobotdfplayermini. ```APIDOC ## reset() ### Description Reset the device to factory defaults. ### Method void ### Parameters None ### Return void ### Example ```cpp myDFPlayer.reset(); ``` ``` -------------------------------- ### DFPlayer Mini Volume Up Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to increase the volume by one level. This command does not require any specific parameters. ```text Code: 0x04 Method: volumeUp() Parameter: 0x0000 ``` -------------------------------- ### DFPlayer Mini Loop Specific File Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/protocol-reference.md Sends a command to loop a specific file. The file number is provided as a 16-bit parameter. ```text Code: 0x08 Method: loop(fileNum) Parameter: fileNum ``` -------------------------------- ### Play a File from a Specific Folder Source: https://github.com/dfrobot/dfrobotdfplayermini/blob/master/_autodocs/README.md Plays a specific file from a numbered folder on the SD card. The first parameter is the folder number, and the second is the file number within that folder. ```cpp myDFPlayer.playFolder(15, 4); // Play SD:/15/004.mp3 ```