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
  1. Arduino UNO
  2. Speaker or Headphone
  3. SD card module
  4. Connecting Wires
  5. SD card
Steps to follow:
Step 1
Follow the below-mentioned circuit diagram to build the circuit.
IoT
  • CS pin to 4th pin
  • SCK pin to 13th pin
  • MOSI pin to 12th Pin
  • MISO pin to 11th pin
  • Audio output pin- 9th 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.
IoT
Step 3
Open Arduino software.
IoT
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.
IoT
Step 5
Initialize the coding by including all the header files required, like SPI.h, SD.h, TMRpcm.h, etc.:
IoT
Step 6
Initialize the Arduino pins in the Void setup.
IoT
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.
IoT
Step 8
Compile and run the code.
IoT
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.