Arduino Mega - MP3 Player
This guide shows you how to make an MP3 player with an Arduino Mega, an MP3 module, a micro SD card, and a speaker. The MP3 module reads music or sound files from the micro SD card. The Arduino Mega tells the MP3 module which song to play, starts the playback, turns it into an audio signal, and sends this signal to the speaker. We will explain these steps in simple terms.
- How to connect a speaker and MP3 modules to the Arduino Mega board
- How to program the Arduino Mega to play a song from a micro SD card
- How to add play, pause, next, and previous buttons
Then you can modify the code to add a volume knob or dial to control the volume.

Hardware Preparation
| 1 | × | Arduino Mega | |
| 1 | × | USB 2.0 cable type A/B (for USB-A PC) | |
| 1 | × | USB 2.0 cable type C/B (for USB-C PC) | |
| 1 | × | Serial MP3 Player Module | |
| 1 | × | Micro SD Card | |
| 1 | × | 3.5mm Aux Speaker | |
| 1 | × | Jumper Wires |
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 .
Overview of Serial MP3 Player Module and Speaker
Serial MP3 Player Module Pinout
A serial MP3 player module has three ports:
- The connection to the Arduino Mega: four pins
- RX pin: for data. Connect to the Mega’s TX pin using either Hardware Serial or Software Serial.
- TX pin: for data. Connect to the Mega’s RX pin using either Hardware Serial or Software Serial.
- VCC pin: power. Connect to 5V.
- GND pin: ground. Connect to 0V.
- The connection to the speaker: a 3.5 mm female aux jack.
- The connection to the Micro SD Card: the Micro SD card socket is at the back of the module.

Speaker Pinout
A speaker usually has two connectors:
- Audio connection: Uses a 3.5 mm AUX plug to connect to the MP3 player.
- Power connection: It can use USB, a 5V power adapter, or other power sources.
How It Works
What we need to prepare:
- Put songs or audio files on a microSD card.
- Put the microSD card into the MP3 player module.
- Connect the MP3 player module to the Arduino Mega board.
- Connect the MP3 player module to a speaker.
- Connect the speaker to a power source.
Each MP3 file on the microSD card has a number that starts at 0 to show the order of the songs.
We can now set up the Arduino Mega to send commands to the MP3 player module. It can handle these commands:
- Play
- Stop
- Next
- Previous
- Volume
The MP3 player module plays the MP3 file on the micro SD card, converts it to an audio signal, and sends the signal to the speaker through the 3.5 mm AUX jack.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Arduino Mega Code - Play Music
The code below starts playing the first song saved on the micro SD card.
Detailed Instructions
Follow these steps one by one.
- Connect the parts as shown in the diagram.
- Connect the Arduino Mega to your computer with a USB cable.
- Open the Arduino IDE on your computer.
- Choose the correct board (Arduino Mega) and the correct COM port.
- Follow the steps in the How It Works section.
- Copy the provided code and paste it into the Arduino IDE.
- Click the Upload button in the Arduino IDE to send the code to the Arduino Mega.
- Have fun making music.
