How to Make a Music Player using Arduino?

Table of Contents

In this project, I will show you how to make a simple Music Player using Arduino and a Micro SD Card Reader / Module. Using this project, you can play audio files (of specific format) that are stored on a microSD Card using Arduino Uno or Mega.


Making your own Music Player using Arduino Uno is an exciting little project. This project doesn’t necessarily need to be a powerful music player but rather to check the ability of the Arduino Uno or any other Arduino boards to play audio files with the help of supporting library files, thanks to the outstanding work of Arduino Community.

Once you have a circuit using Arduino Uno, a microSD Card Module (Adapter), a microSD Card and speakers or headphones, you can implement several sound effects in your projects, which are not possible under normal circumstances.

Guide to Interface SD Card Module with Arduino

As mentioned earlier, the main components of the Arduino based Music Player project are Arduino board and SD Card Module / Adapter. The audio files stored in a microSD card (more about audio files later) are read by Arduino with the help of SD Card Module and played through a speaker.

So, it is very important that you understand how to interface an SD Card Module with Arduino and read / write data from / to a microSD Card.

Music Player using Arduino SD Card Module

I have already implemented a tutorial on how to interface an SD Card Module with Arduino Uno. Check out that project first and if possible, try to implement it before proceeding with this project.

Arduino SD Card Module Interface

Circuit Diagram

The following image shows the circuit diagram of the project. Note that the circuit diagram shows only the connections between Arduino Uno and SD Card Adapter and three buttons connected to Arduino, which control the playback functions like Play / Pause, previous track and next track.

Additionally, a speaker is connected to Arduino, but it is not shown in the circuit diagram. The connections between Arduino and the speaker (or headphones) are the positive connection of the speaker / headphone is connected to Pin 9 of Arduino and the negative pin is connected to GND.

Music Player using Arduino Circuit Diagram

Components Required

  • Arduino UNO (or any Arduino Board)
  • SD Card Adapter / Module
  • microSD Card
  • Small Speakers
  • 3 x Push Buttons
  • Breadboard
  • Connecting Wires

Circuit Design of Music Player using Arduino

As mentioned earlier, the speaker is connected to Pins 9 and GND (not shown in the circuit diagram). Additionally, we need to connect SD Card Module and 3 Push Buttons.

Since the interface between Arduino UNO and SD Card Module is through SPI Communication, the connections the connections are as follows.

The CS Pin of SD Card Module is connected to Pin 4. Chip Select (CS) pin can be connected to any Digital I/O Pin but the rest of the SPI Pins of SD Card Module must be connected to corresponding SPI Pins of Arduino.

SCK or SPI Clock Pin of SD Card is connected to Pin 13 of Arduino. The MOSI and MISO pins of SD Card Module are connected to Pins 11 and 12 of Arduino UNO respectively.

The power pins i.e. VCC and GND are connected to +5V and GND of Arduino.

Additionally, I have used 3 push buttons to control the music playback. Play / Pause Button is connected to Pin 5, Next Track Button is connected to Pin 6 and Previous Track Button is connected to Pin 7 of Arduino. All these buttons are configured with internal pullups in the program.

Preparing Audio Files and PCM Library

WAV Files

Before proceeding further, there are a couple of things you need to take care of. The first one is to convert your audio / music files to WAV format i.e. they should be .wav files. This is because, the supporting libraries, which I will mention next, support only PCM Audio in WAVE File Format (.wav).

So, your first step is to convert your mp3 files to .wav files. For this you can use any audio converter software, the convert option in VLC Media Player or any online tools. I will be using an online tool called It supports multiple files like archives, audio, documents etc.

Go to the Audio converter option in the website and select “Convert to WAV” option or simple use this URL: Online Music Converter.

Upload the mp3 file and in the optional settings, set the following:

  • Change bit resolution: 8 Bit
  • Change sampling rate: 16000 Hz
  • Change audio channels: mono
  • PCM format: PCM unsigned 8-bit

After making the above-mentioned changes, click on start conversion and the converted file will be downloaded automatically.

PCM Library

The second important thing is to add a special library called TMRpcm developed by TMRh20. You can download it directly from the official GitHub page or you can add it directly in the Arduino IDE.

In Arduino IDE, go to Tools Manage Libraries… and search for “TMRpcm” and click on install.

NOTE: This project also requires SPI and SD libraries. These are built-in libraries.



#include <SD.h> // need to include the SD library
#define SD_ChipSelectPin 4 //connect pin 4 of arduino to cs pin of sd card
#include <TMRpcm.h> //Arduino library for asynchronous playback of PCM/WAV files
#include <SPI.h> // need to include the SPI library
TMRpcm tmrpcm; // create an object for use in this sketch
int temp=1;
int pp=5;
int next=6;
int prev=7;
void setup()
tmrpcm.speakerPin = 9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
if (!SD.begin(SD_ChipSelectPin)) // returns 1 if the card is present
Serial.println(SD fail);
tmrpcm.setVolume(5); //; //the sound file “song” will play each time the arduino powers up, or is reset
//try to provide the file name with extension
void loop()
while(digitalRead(pp)==0 || digitalRead(next)==0 || digitalRead(prev)==0)
else if(digitalRead(next)==0)
if(temp<4)//temp should be lesser than no. of songs
else if(digitalRead(prev)==0)
void song (void)
else if(temp==2)
else if(temp==3)
else if(temp==4)


Working of Arduino based Music Player

After making the hardware connections as mentioned earlier, getting audio files ready, setting up the Arduino IDE (install libraries), you are ready to implement you own music player using Arduino.

First, format the microSD Card as FAT using any formatting software like SD Memory Card Formatter and copy all the WAV audio files to the card. Insert the card into the slot on the SD Card Module and make all the necessary connections (if not made already).

Music Player using Arduino Working Image

Connect Arduino UNO to computer and in the Arduino IDE, use the above given code. In the code, make necessary changes i.e. in the void song () function, replace the file names with the song names in your SD card.

I have named all my audio files as song1.wav, song2.wav, etc. and used the same names in the function. After making necessary changes, upload the code.

By default, the first song (i.e. song1.wav for me) will play automatically once the Arduino is reset. You can use the Play / Pause Button to well, play or pause the current track. Use Next Button to play the next track and Prev Button to play the previous track.


  • A simple DIY Project called Music Player using Arduino is implemented here, where you can play audio files using Arduino UNO.
  • This project supports WAV Audio files and also control the playback of the audio.
  • You can use an additional Amplifier like LM386 IC to boost the output power.
  • Using this project, you can implement audio effect in your Arduino Projects.

Similar Articles & Blogs

Explore similar articles on various electronics and electrical topics – 


We saw in the previous tutorial about the binary weighted digital-to-analogue converter that the analogue output voltage is the weighted sum of the individual inputs, and that

Learn More >>

Analogue to Digital Converter

Analogue-to-Digital Converters, (ADCs) allow micro-processor controlled circuits, Arduinos, Raspberry Pi, and other such digital logic circuits to communicate with the real world. In the real

Learn More >>

Transmission Gate

The analogue switch is a solid-state semiconductor switch that controls the transmission path of analogue signals. The open and closed operations of the switch positions

Learn More >>

Binary Adder

Another common and very useful combinational logic circuit which can be constructed using just a few basic logic gates allowing it to add together two

Learn More >>

Bus Transceiver

A Transceiver can be used to provide bidirectional, input or output control, of either digital or analogue devices to a common shared data bus. Unlike the buffer,

Learn More >>

Digital Comparator

Digital or Binary Comparators are made up from standard AND, NOR and NOT gates that compare the digital signals present at their input terminals and produce an output depending upon

Learn More >>