Arduino Nano - Mini Mp3 Player Module
This guide shows you everything you need to get the DIYables Mini Mp3 Player module working with an Arduino Nano. By the end, you will know how to:
- Wire the Mini Mp3 Player to an Arduino Nano on a breadboard.
- Play, pause, resume, and stop mp3 tracks.
- Control volume with physical buttons or serial commands.
- Skip forward and backward through tracks.
- Loop individual tracks, loop all tracks, or shuffle playback.
- Organize and play tracks from numbered folders.
- Read back the current volume, track number, and playing state.

What You'll Need
Or you can buy the following kits:
| 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 .
Getting to Know the Mini Mp3 Player Module
The DIYables Mini Mp3 Player module packs the YX5200-24SS decoder chip into a tiny board. Slide in a micro SD card loaded with mp3 files, hook up a speaker, and you have a standalone audio player that your Nano controls over a simple serial connection.
Here is what the module can do:
- Playback controls: play, pause, resume, stop, next, previous
- Volume: adjustable from 0 (silent) to 30 (maximum)
- EQ presets: Normal, Pop, Rock, Jazz, Classic, Bass
- Repeat modes: loop one track, loop a folder, loop all, shuffle
- Folders: organize tracks into numbered folders for easy selection
- Advertisements: interrupt the current track, then continue where you left off
- Status queries: ask the module what track is playing, the current volume, etc.
All communication happens over UART at 9600 baud — just two wires (TX and RX) plus power.
Pinout Reference
| Pin | What It Does | |
|---|---|---|
| VCC | Power in (3.2V – 5.0V) | |
| GND | Ground connection | |
| RX | Receives serial commands from the Nano (through 1K resistor) | |
| TX | Sends serial data back to the Nano | |
| SPK_1 | Positive speaker terminal (built-in 3W amp) | |
| SPK_2 | Negative speaker terminal | |
| DAC_R | Right audio line out (for external amp) | |
| DAC_L | Left audio line out (for external amp) | |
| BUSY | Goes LOW while a track is playing | |
| IO_1 | Trigger | short press = previous, long press = vol down |
| IO_2 | Trigger | short press = next, long press = vol up |

How to Wire It Up
Since the Arduino Nano runs at 5V, you must place a 1K resistor between the Nano's TX pin and the module's RX pin. This drops the voltage to a safe level for the module's 3.3V logic.
| Mini Mp3 Player | Arduino Nano | Notes |
|---|---|---|
| VCC | 5V | |
| GND | GND | |
| RX | D11 | Use a 1K resistor in series! |
| TX | D10 | |
| SPK_1 | Speaker + | |
| SPK_2 | Speaker − |
Both the Nano and the Mini Mp3 Player fit comfortably on a standard breadboard, making this a very compact build.

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Nano and other components.
Setting Up the SD Card
Before inserting the card into the module:
- Format it as FAT16 or FAT32.
- Copy mp3 files to the root with zero-padded numbers:
- For folder playback, create numbered folders:
Watch out: The module numbers tracks by the order they were copied to the card, not by the filename. Format the card first, then copy each file one at a time in the right order.
- Folder names: 01 to 99 (two digits, zero-padded)
- File names inside folders: 001 to 255 (three digits, zero-padded)
- Track numbering starts at 1, not 0
Library Installation
- Plug the Nano into your computer via the Mini-B USB cable.
- Open Arduino IDE, choose Arduino Nano as the board and pick the right COM port.
- Click the Libraries icon in the left sidebar of the Arduino IDE.
- Search for "DIYables_MiniMp3" and find the library by DIYables.
- Hit Install.

No additional dependencies are needed — the library is completely self-contained.
Starter Template
Here is the minimum code structure you need for every sketch using this module:
The delay(1000) after begin() is important — the module needs about a second to initialize after power-on. Always set the volume explicitly, because the default may be 0 (silent).
Code Example — Play One Track
Plays track 001.mp3 once and stops.
Steps to Try It
- Load your SD card with at least one mp3 file (001.mp3).
- Insert the SD card into the module and wire everything as shown above.
- Connect the Nano to your PC via USB.
- In the Arduino IDE, select Arduino Nano and the correct port.
- Paste the code and click Upload.
Track 1 plays through the speaker.
Playback Quick Reference
| Function | Description | Example Code |
|---|---|---|
| play(track) | Play a specific track | mp3.play(1) |
| playNext() | Jump to next track | mp3.playNext() |
| playPrevious() | Jump to previous track | mp3.playPrevious() |
| pause() | Pause current track | mp3.pause() |
| resume() | Continue paused track | mp3.resume() |
| stop() | Stop playback | mp3.stop() |
Code Example — Play Multiple Tracks
Cycles through several tracks one at a time.
Steps to Try It
- Put at least 3 mp3 files on the SD card.
- Upload the code. Tracks play in a loop with a 5-second interval.
Code Example — Loop a Track Forever
Repeats a single track on an endless loop.
Steps to Try It
- Upload the code. Track 1 repeats indefinitely.
Repeat & Shuffle Quick Reference
| Function | Description | Example Code |
|---|---|---|
| loopTrack(track) | Repeat one track nonstop | mp3.loopTrack(1) |
| loopFolder(folder) | Repeat all tracks in a folder | mp3.loopFolder(1) |
| loopAll() | Repeat every track on the card | mp3.loopAll() |
| stopLoop() | Cancel the current loop | mp3.stopLoop() |
| shuffle() | Random playback of all tracks | mp3.shuffle() |
Code Example — Folder Playback
Select and play tracks from specific numbered folders on the SD card.
Steps to Try It
- Create folders (01, 02) on the SD card with numbered mp3 files inside.
- Upload the code. It plays from folder 01, then folder 02.
Folder Playback Quick Reference
| Function | Description | Example Code |
|---|---|---|
| playFolder(f, t) | Play track t from folder f (99 folders max, 255 tracks) | mp3.playFolder(1, 1) |
| playLargeFolder(f, t) | Play from folder (15 folders max, 3000 tracks) | mp3.playLargeFolder(1, 500) |
| playFromMP3Folder(t) | Play from the special /mp3 folder | mp3.playFromMP3Folder(1) |
Code Example — Serial Monitor Remote
Control playback entirely from the Serial Monitor — great for testing.
Steps to Try It
- Upload the code, open Serial Monitor at 9600 baud, and type commands.
Command Reference
| Type | What Happens |
|---|---|
| 1–9 | Plays that track number |
| + | Volume up |
| − | Volume down |
| p | Pause |
| r | Resume |
| s | Stop |
| n | Next track |
| b | Back (previous track) |
| ? | Show status info |
EQ Presets
| Constant | Value | Style | ||
|---|---|---|---|---|
| DIYables_MiniMp3 | EQ_NORMAL | 0 | Flat | |
| 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 heavy |
Reading Module Status
These calls let you check what the module is doing. Each one blocks briefly (up to 100 ms) while waiting for the reply. Returns −1 if the module doesn't respond.
| Function | Returns | What You Get |
|---|---|---|
| isPlaying() | bool | true if audio is currently playing |
| getVolume() | int16_t | Volume level (0–30) |
| getEQ() | int16_t | Active equalizer preset (0–5) |
| getTrackCount() | int16_t | Total number of tracks on the card |
| getCurrentTrack() | int16_t | Track number that's playing right now |
| getFolderCount() | int16_t | How many folders are on the card |
| getTrackCountInFolder(f) | int16_t | How many tracks are in folder f |