Arduino Wave Audio Player with SD Card

This article shows how to easily play wave audio files (files with .WAV extension) using Arduino UNO board. The Arduino loads wave audio files from FAT16 or FAT32 formatted SD card and a simple PC speaker is used to amplify the audio signal generated by the Arduino microcontroller.

Wave audio file is a Microsoft and IBM audio file format standard for storing an audio bitstream on PCs. The good thing with this format is that it is not compressed, this allows even a small microcontroller to play it.
Usually a DAC (Digital-to-Analog Converter) is used to generate sound. The Arduino UNO microcontroller (ATmega328P) doesn’t have a DAC module, therefor PWM (Pulse Width Modulation) is used instead of DAC. A higher PWM frequency should give better sound output.
The sound is generated by varying the duty cycle of the PWM signal.

For better results, the wave audio file should have the following characteristics:
Format : PCM
Format settings : Unsigned
Sampling rate: 16.0kHz
Bit depth: 8 bits
Number of channels: mono (1 channel)

If we have a MP3 audio file we can convert it to a .wav format using a software named: Audacity. It’s a free and open source converter.
Audacity official website:

How to convert MP3 file to WAV file:
This example shows how to convert MP3 into WAV using Audacity converter.

First, open Audacity software, a window will open as shown below:

Audacity audio converter

Go to: File —> Open… and open the MP3 file.

Click on the file name then on Split Stereo to Mono as shown below:

Audacity convert stereo to mono

Now click on X and change the sampling rate to 16000:

Audacity change sampling rate

After that, go to File —> Export —> Export as WAV, a new window will open.
Change Save as type to Other uncompressed files and save your wave file.

Audacity save wav file

And you’ll get your file with WAV format!

Hardware Required:

  • Arduino UNO board
  • microSD card with FAT16 or FAT32 file system
  • microSD card module adapter
  • Audio amplifier (ex: PC speaker, LM386 …)
  • Speaker
  • 1k ohm resistor
  • 2 x Push button
  • 10uF capacitor
  • Breadboard
  • Jumper wires

Arduino wave audio player with SD card circuit:
The following image shows project circuit diagram.

Arduino wave audio player sd card circuit
Arduino wave audio player circuit

Arduino digital pin 9 is the audio output (PWM signal), it’s connected to the audio amplifier.
Audio amplifier ground must be connected to Arduino ground (any GND pin).

In this project I used microSD card module, this module is supplied from circuit 5V source that comes from the Arduino UNO board. This module contains AMS1117-3V3 voltage regulator which is used to supply the micro SD card with 3.3V. Also this module contains an IC which is 74LVC125A and it’s used as level translator (from 5V to 3.3V).

The microSD card module is connected to the Arduino as follows (from left to right):
The first pin of the micro SD card module (GND) is connected to Arduino GND,
The second pin of the micro SD card module (VCC) is connected to Arduino 5V,
The third pin of the micro SD card module (MISO) is connected to Arduino digital pin 12,
The fourth pin of the micro SD card module (MOSI) is connected to Arduino digital pin 11,
The fifth pin of the micro SD card module (SCK) is connected to Arduino digital pin 13,
The last pin of the micro SD card module (CS) is connected to Arduino digital pin 10.

The digital pins 10, 11, 12 and 13 are hardware SPI module pins of ATmega328P microcontroller (Arduino UNO microcontroller).

Arduino wave audio player with SD card circuit:
The following Arduino code requires TMRpcm library which allows us to easily play wave files from SD card. This library can be installed from Arduino IDE library manager (Sketch —> Include Library —> Manage Libraries …, in the search box write “tmrpcm” and click on Install).

Or it can be installed manually, first download the TMRpcm library from the following link:
TMRpcm Library   —> direct link

After the download, go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).

There is no need to specify wave audio file names, the Arduino will search and play all the wave audio files located in the main root of the SD card.
When the ‘Next’ button is pressed, the Arduino will play the next wave file.

There are 3 libraries included in the main code as shown below.
Including Arduino SPI library is optional!

Rest of code is described through comments.

Full Arduino code:

The following video shows a simple test circuit:

Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

9 thoughts on “Arduino Wave Audio Player with SD Card”

  1. Hello, thank you for the code ! The initialization keeps failing when I try… I checked the wiring, the micro sd works on my computer, do you know what could be the problem ?
    Thank you for your help

  2. Maybe it is worth mentioning that in order to hook up a digital 5v pp signal to an amplifier, it requirs a RC network to adjust it to a somewhat more analogue signal.
    I was advised to use 3x 3k3 resistors on the output, and after every resistor, place a 10nF capacitor to GND.
    That was wat did the job in my case.

    Now I have to find a way to select the file from the SD card on demand, when needed.

  3. Great project.but for some reason mine doesn’t work. Also when I save it as you’ve shown, it saves it as VLC media file (.aiff). Any suggestions?

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top