Introduction
In this article, we will see how to play audio using the SD card Module and Arduino. We have to save the audio in .wav file and specifically command the Arduino to play the audio at the specific digital pin. The volume of the audio can also be adjusted in the coding as per the requirement.
Requirements
- Arduino UNO
- Speaker or Headphone
- SD card module
- Connecting Wires
- SD card
Steps to follow:
Step 1
Follow the below-mentioned circuit diagram to build the circuit.

- CS pin to 4
th pin - SCK pin to 13
th pin - MOSI pin to 12
th Pin - MISO pin to 11
th pin - Audio output pin- 9
th Pin.
Place the SD card in the SD card module.
Step 2
Select any audio and convert it into 8 bit, monotype Wav file. Save it in the name of 1.wav file and 2.wav file.
Please refer to the website: https://audio.online-convert.com/convert-to-wav.

Step 3
Open Arduino software.

Step 4
Include the header file in the coding. TRMpcm Header file will be available on the link: https://www.arduinolibraries.info/libraries/tm-rpcm. Download and include the header file.

Step 5
Initialize the coding by including all the header files required, like SPI.h, SD.h, TMRpcm.h, etc.:

Step 6
Initialize the Arduino pins in the Void setup.

Step 7
Create a function “Play” and include the details of the audio to be played. The output pin selection, audio volume selection, start timing selection are done.

Step 8
Compile and run the code.

Output
The output is taken from the 9th pin. Connect it to a speaker or headphone. You can hear the audio playing.
Summary
In this article, we saw how to work with the SD card module to make an audio player.

Kevin BartoloPosted Sep 9, 2021, 12:42 AM
I am going back to a Nano board instead of the Nano33BLE which has no information about audio playback. I need to play only four one and two word audio files, is it possible to modify this code to use flash memory to save the files on instead of an SD card?
Kevin BartoloPosted Aug 31, 2021, 12:58 AM
G'day from Australia. I have a project needing to produce a few one and two word audio on an Arduino Nano33BLE. I am finding it hard to find a solution as not a lot of projects for the Nano33BLE format yet, and, the change in processors from the Nano and UNO formats don't all work on the Nano33BLE. Will the TMRpcm library work on the Nano33BLE? Or can you suggest a solution for me. I was looking at using FLASH memory for sound files as I found some examples using this and creating .h files for each sound file, as I am trying to make this as physically small as possible.
Berat SinaniPosted Apr 7, 2021, 9:47 PM
Dear, I have create same case but when I am hitting button to play audio, first I hear a noise like a channelless radio then the rest hear the recorded voice.
glitch216 glitch216Posted Jun 2, 2019, 8:48 AM
Where does pcmconfig come in to this it gets detected as an error when i run the code
Hadshana KamalanathanPosted Jul 21, 2018, 10:04 AM
Thanks for sharing