Arduino Audio Player with SD Card Module
Overview
In this Arduino tutorial, we will learn how to make an audio player using Arduino and SD card module. Any kind of micro-controller project will look cool and interesting when we adding sounds. We can easily interfacing SD card module and Arduino. Also, we have easily found some Arduino libraries.You can watch the following video below:-
Components Required
The required equipment for this project list given below:-- Arduino Uno
- Micro SD card Adapter
- Micro SD card
- Card Reader
- Speaker with 3.5mm jack output
- Some Jumper wire
Convert Audio To .Wav Format
If you want to play any audio file with Arduino you must need to convert the audio in wav format because Arduino can play through SD card module an audio file in a specific format. Now follow the below procedure to convert an audio file in wav format.
- Go to the link: https://audio.online-convert.com/convert-to-wav
- Upload your audio you want to convert to WAV
- Set bit resolution: " 8bit ".
- Change sampling rate: " 16000Hz ".
- Fixed audio channels: " mono ".
Next click on "Convert file" and download the file.
Circuit Schematic
The circuit schematic of the audio player given below:-
Fig: Circuit Diagram |
Circuit Description
SD card module has six pins whose Vcc and GND pin will connect with Arduino 5V and GND pin respectively. Next comes to MISO, MOSI and SCK pin which use for SPI communication with Arduino. These pins will connect with Arduino digital pin 12, 11 and 13 respectively. Last one CS pin will connect to digital pin 10.
After that Arduino digital pin 9 will connect to sleeve end of the speaker 3.5mm jack. The tip end of the speaker jack will go to the ground pin of the Arduino.
You can download the library here: https://github.com/TMRh20/TMRpcm
Fig: 3.5mm Jack |
Source Code
The source code is given below:-
#include <SD.h> // need to include the SD library
//#define SD_ChipSelectPin 53 // example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 10 // using digital pin 10 on arduino uno 328, can use other pins
#include <TMRpcm.h> // also need to include this library...
#include <SPI.h>
TMRpcm tmrpcm;
void setup()
{
tmrpcm.speakerPin=9; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
//Complimentary Output or Dual Speakers:
//pinMode(10,OUTPUT); Pin pairs: 9,10 Mega: 5-2,6-7,11-12,46-45
Serial.begin(9600);
if(!SD.begin(SD_ChipSelectPin))
{
Serial.println("SD fail");
return;
}
tmrpcm.setVolume(6);
tmrpcm.play("test.wav");
}
void loop() {
// put your main code here, to run repeatedly:
}
You can download the library here: https://github.com/TMRh20/TMRpcm
No comments