Arduino UNO R4 - Mini Mp3 Player Module
In this tutorial, you will learn how to use the DIYables Mini Mp3 Player module with the Arduino Uno R4 (both WiFi and Minima variants). We will cover:
- Wiring the Mini Mp3 Player to the Arduino Uno R4.
- Playing mp3 tracks stored on an SD card.
- Adjusting volume, including volume up and volume down.
- Pausing, resuming, and stopping playback.
- Navigating tracks (next and previous).
- Looping a single track, looping all tracks, and shuffling.
- Playing specific tracks from numbered folders.
- Querying the playback status.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables STEM V4 IoT Starter Kit (Arduino included) | |
| 1 | × | DIYables Sensor Kit (30 sensors/displays) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Mini Mp3 Player Module
The DIYables Mini Mp3 Player is a compact mp3 decoder module built around the YX5200-24SS chip. It plays mp3 files directly from a micro SD card and can drive a speaker (up to 3W) through its onboard amplifier, or output line-level audio via DAC pins for use with an external amplifier.
Communication happens over UART at 9600 baud, making it straightforward to control from any Arduino board. Key capabilities include:
- Play, pause, resume, and stop
- Volume adjustment from 0 to 30
- Six equalizer presets: Normal, Pop, Rock, Jazz, Classic, Bass
- Track looping, folder looping, full shuffle
- Folder-based playback with numbered directories
- Interrupt playback with advertisements
- Query current track, volume, play state, and more
Module Pinout
| Pin | Description |
|---|---|
| VCC | Power input (3.2V to 5.0V) |
| GND | Ground |
| RX | Serial data in — connect to Arduino TX through a 1K resistor |
| TX | Serial data out — connect to Arduino RX |
| SPK_1 | Speaker positive terminal (direct drive, 3W max) |
| SPK_2 | Speaker negative terminal (direct drive, 3W max) |
| DAC_R | Right channel line output (for external amplifier) |
| DAC_L | Left channel line output (for external amplifier) |
| BUSY | LOW during playback, HIGH when idle |
| IO_1 | Short press = previous track, long press = volume down |
| IO_2 | Short press = next track, long press = volume up |

Wiring Diagram
The Arduino Uno R4 operates at 5V logic, so a 1K resistor is required on the module's RX line to protect its 3.3V input.
| Mini Mp3 Player Pin | Arduino Uno R4 Pin | Note |
|---|---|---|
| VCC | 5V | |
| GND | GND | |
| RX | Pin 11 | Via 1K resistor (required for 5V boards) |
| TX | Pin 10 | |
| SPK_1 | Speaker + | |
| SPK_2 | Speaker − |

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Uno R4 and other components.
Tip: The Uno R4 has a hardware serial port (Serial1 on pins 0 and 1), but since pin 0/1 are shared with USB, using SoftwareSerial on pins 10/11 is the safer approach.
Preparing the SD Card
- Format the micro SD card as FAT16 or FAT32.
- Copy your mp3 files to the root directory using zero-padded names:
- For folder-based playback, create numbered folders with numbered files:
Key points:
- Track numbering begins at 1, not 0.
- The module determines track order by the sequence in which files are copied, not by filename. Always format the card first, then copy files one at a time in the desired order.
- Folder names: 2-digit, zero-padded (01 through 99).
- Filenames inside folders: 3-digit, zero-padded (001 through 255).
Installing the Library
- Plug the Arduino Uno R4 into your computer using a USB-C cable.
- Open the Arduino IDE and select the correct board and port.
- Click the Libraries icon on the left sidebar.
- Type "DIYables_MiniMp3" in the search box and locate the library by DIYables.
- Click Install to add the latest version of the library.

This library has no external dependencies.
Arduino Uno R4 Code - Play a Single Track
The sketch below plays one mp3 track from the SD card.
How To Run
- Prepare an SD card with mp3 files (001.mp3, 002.mp3, etc.) and insert it in the module.
- Wire the Mini Mp3 Player to the Uno R4 according to the wiring diagram above.
- Connect the Uno R4 to your computer with a USB-C cable.
- Open the Arduino IDE, choose Arduino Uno R4 WiFi (or Minima) as the board and select the correct port.
- Paste the code above into the IDE editor.
- Press Upload.
You should hear track 001.mp3 through the speaker.
Playback Functions at a Glance
| Function | What It Does | Usage |
|---|---|---|
| play(trackNum) | Starts a specific track | mp3.play(1) |
| playNext() | Skips to the next track | mp3.playNext() |
| playPrevious() | Goes back to the previous track | mp3.playPrevious() |
| pause() | Pauses the current track | mp3.pause() |
| resume() | Resumes a paused track | mp3.resume() |
| stop() | Stops playback entirely | mp3.stop() |
Arduino Uno R4 Code - Play Multiple Tracks in Sequence
This sketch plays several tracks one after another, with a configurable delay between each.
How To Run
- Make sure the SD card contains at least 3 tracks (001.mp3, 002.mp3, 003.mp3).
- Upload the code to the Uno R4.
Tracks 1 through 3 will play in a repeating cycle with a 5-second gap.
Arduino Uno R4 Code - Pause and Resume Toggle
A single button toggles playback between paused and playing.
How To Run
- Wire a button to pin 2, then upload.
- Press the button once to pause, press again to resume.
Arduino Uno R4 Code - Loop a Track
This sketch repeats a single track endlessly.
How To Run
- Upload the code. Track 001.mp3 will loop continuously.
Repeat and Shuffle Functions
| Function | What It Does | Usage |
|---|---|---|
| loopTrack(trackNum) | Repeats one track forever | mp3.loopTrack(1) |
| loopFolder(folder) | Repeats every track in a folder | mp3.loopFolder(1) |
| loopAll() | Repeats all tracks on the card | mp3.loopAll() |
| stopLoop() | Cancels any active loop | mp3.stopLoop() |
| shuffle() | Plays all tracks in random order | mp3.shuffle() |
Arduino Uno R4 Code - Play from a Folder
Play tracks from specific numbered folders on the SD card.
How To Run
- Set up the SD card with folders (01, 02) containing numbered files (001.mp3, 002.mp3).
- Upload the sketch. It plays tracks from folder 01 then folder 02.
Folder Playback Functions
| Function | What It Does | Usage |
|---|---|---|
| playFolder(folder, track) | Plays a track from a folder (up to 99 folders, 255 tracks) | mp3.playFolder(1, 1) |
| playLargeFolder(folder, track) | Plays from a folder (up to 15 folders, 3000 tracks) | mp3.playLargeFolder(1, 1500) |
| playFromMP3Folder(trackNum) | Plays from the /mp3 folder | mp3.playFromMP3Folder(1) |
Arduino Uno R4 Code - Serial Monitor Control
Type single-character commands in the Serial Monitor to control every aspect of playback. No extra hardware needed.
How To Run
- Upload the code, then open the Serial Monitor at 9600 baud.
- Enter any command from the table below:
| Key | Action |
|---|---|
| 1–9 | Play track number 1 through 9 |
| + | Turn volume up |
| − | Turn volume down |
| p | Pause playback |
| r | Resume playback |
| s | Stop playback |
| n | Skip to next track |
| b | Go back to previous track |
| ? | Print current status |
Equalizer Modes
Six built-in EQ presets are available:
| Constant | ID | Sound Profile | ||
|---|---|---|---|---|
| DIYables_MiniMp3 | EQ_NORMAL | 0 | Flat / neutral | |
| DIYables_MiniMp3 | EQ_POP | 1 | Pop | |
| DIYables_MiniMp3 | EQ_ROCK | 2 | Rock | |
| DIYables_MiniMp3 | EQ_JAZZ | 3 | Jazz | |
| DIYables_MiniMp3 | EQ_CLASSIC | 4 | Classical | |
| DIYables_MiniMp3 | EQ_BASS | 5 | Bass emphasis |
Querying Playback Status
The following functions let you read the module's state at runtime. Each call blocks for up to 100 ms while waiting for a reply. A return value of −1 indicates an error or timeout.
| Function | Return Type | Description |
|---|---|---|
| isPlaying() | bool | true while a track is actively playing |
| getVolume() | int16_t | Current volume level (0–30) |
| getEQ() | int16_t | Active EQ preset (0–5) |
| getTrackCount() | int16_t | Number of tracks on the SD card |
| getCurrentTrack() | int16_t | Track number currently playing |
| getFolderCount() | int16_t | Number of folders on the SD card |
| getTrackCountInFolder(folder) | int16_t | Tracks inside a specific folder |