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 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.
Step 3
Open Arduino software.
Step 4
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.
In this article, we saw how to work with the SD card module to make an audio player.