The SD Card Module is used for transferring data to and from the memory card. It allows for mass storage that we can be used in our project especially in data logging. And this tutorial aims to play audio files with your Arduino in decent quality from SD card.
What Will I Learn?
How to use SD Card module
Playing music with the use of Arduino
Requirements
Arduino Uno
SD Card Module
SD Card
Speaker
Connecting Wires
Difficulty
Basic
Tutorial Contents
Step 1: Physical Connection from SD Card Module to Arduino Uno
Connect the following:
VCC to 5V of Arduino Uno
GND to GND of Arduino Uno
CS to pin 4 of Arduino Uno
SCK to pin 13 of Arduino Uno
MOSI to pin 11 of Arduino Uno
MISO to pin 12 of Arduino Uno
the 5V of speaker to pin 9 of Arduino Uno
GND of speaker to GND of Arduino Uno
Step 2: Software Connection
Connect the USB Cable to a PC/Laptop
Open your Arduino IDE, change your board to Arduino Uno: Go to Tools > Board: > Arduino/Genuino Uno
And also, change the Port settings: Go to Tools > Port: > COM6 (Arduino/ Genuino Uno)
Then, download the library TMRpcm for asynchronous playback of PCM/WAV files direct from SD card. After downloading, extract the file and copy the folder then Go to your Program Files and find the Arduino Folder > libraries then paste the folder of TMCprm.
Change the bit resolution to 8 bit, sampling rate to 16000Hz, audio channels to mono. And in advanced options choose the PCM unsigned 8-bit then, convert the file. This will allow the arduino to play the audio file.
Step 4: The Code
Copy the code then compile and run.
My Circuit:
Tip to remember: Before saving an audio file to the SD Card make sure it is WAV formatted because Arduino can only read a PCM signal which the WAV format has.