Audio Player Using Arduino With Micro SD Card


69,186

74

128

i believe to help people and share my knowledge i always want to build creative thing some of the...

Please SUBSCRIBE my channel for more projects.........................

Many of People want to interface the SD card with arduino or want some audio output via arduino.

So here is easiest and cheapest way to interface SD card with arduino . you can use the audio output from arduino via a switch or sensor .

you can play any type of sound ,music and recording but that audio will be in to .wav file. If it is in .mp3 or any other audio type then we will convert it into .wav file.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components & ​Requirements

  • arduino uno
  • micro SD card Adapter module
  • micro SD
  • Card Reader
  • Speaker or earphone speaker
  • woofer or amplifier

Step 2: Convert Audio to .wav

Go to the Link to convert the audio into .wav .

http://audio.online-convert.com/convert-to-wav

  1. Go to The Link
  2. Upload your audio you want to convert to WAV
  3. Change bit resolution to " 8bit ".

  4. Change sampling rate to " 16000Hz ".

  5. Change audio channels " mono " .

  6. Click on " Show advanced options ".

  7. PCM format " unsigned 8 bit ".

  8. Convert file.

At next page click on "direct download link"

Step 3: Prepare SD Card

Download the Zip file and Extract it.

Here you will get the " SD formatter "

install the SD formatter in your PC.

Now, Connect your card with PC via USB card reader.

Open SD card formatter.

Select the drive of sd card then click on format .

In Next Step Open your SD card Drive .

Past the Audio file that we have converted in .wav file

Rename the file to "test.wav".

Step 4: Add Library in Arduino

Open The arduino Software

Click on then Sketch >> Include Library >> Add zip Library

Select "TMRpcm.zip" that is in zip folder.

Step 5: Upload the Codes

Download the code from link below or i have already mentioned in zip file .

Connect your arduino with pc and upload the Codes.

Step 6: ​Circuit Connections

Insert the card in micro sd adapter module.

Connect the circuit as given below.

CS ---------------------->> 10

SCK ---------------------->> 13

MOSI -------------------->> 11

MISO--------------------->> 12

VCC --------------------->> +5v

GND--------------------->> Arduino's Ground

Speaker Connection

one pin is in to 9 pin of Arduino and other is GND of Arduino

Step 7: Play the Audio

Now , It's Ready...............................

Click Reset button to play audio every time.

The OUTPUT sound is very Low so you can use woofer or amplifier for batter Output.

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017

3 People Made This Project!

Recommendations

  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

128 Discussions

0
None
aswtang

Question 9 days ago

Hi, I managed to get the circuit working and playing music, but I'm struggling to get it to work with a sensor. I want to use a microphone sensor to start the music. I've tried merging this code with code for the sensor, but I'm relatively unfamiliar with Arduino and can't get it to work.

The code I've used is;

#include "SD.h"
#define SD_ChipSelectPin 10
#include "TMRpcm.h"
#include "SPI.h"
const int speaker = 9;
const int mic = A0;
const int threshold = 10;
int sensorReading =0;
TMRpcm tmrpcm;
void setup()
{
pinMode (speaker, OUTPUT);
tmrpcm.speakerPin=9;
Serial.begin(9600);
}
void loop() {
{ // put your main code here, to run repeatedly:
if (sensorReading >= threshold)
{(!SD.begin(SD_ChipSelectPin));
{
Serial.println("SD fail");
return;
}
tmrpcm.setVolume(10);
tmrpcm.play("test.wav");
}
delay(100);
}}

0
None
ShivaS68

7 months ago

sir i mixed both backgroud music file and a text audio file and converted to wav. After doing all the uploading work ,when i tried to play in the speaker it just sounds buzzz.

But when i tried to play the files individually , it plays
help....i need to play both files in one time......ASAP

2 replies
0
None
tamias47ShivaS68

Reply 4 months ago

If the two (or more) tracks are always sync'd the same, you could just combine them into a single .wav file using the free program Audacity.

0
None
LiutaurasMShivaS68

Reply 5 months ago

Heyy, same was to me, i just changed few things, just try to use pin 9 for speaker and also use PROGMEM in this code, it will play more clearlier and moreover for me actually playing :D

/* Example sketch using progmem to store wav filenames. Uses
program memory to store filenames instead of ram when playing
many different wav files.
See http://arduino.cc/en/Reference/PROGMEM for more info.
Sketch below based on the above link
*/
#include <avr/pgmspace.h>
#include <TMRpcm.h>
#include <SPI.h>
TMRpcm wav;
#include <SD.h>
#define SD_ChipSelectPin 10
static const char wav_1[] PROGMEM = "beeps/beep-8";
static const char wav_2[] PROGMEM = "warning.wav";
static const char wav_3[] PROGMEM = "verified.wav";
static const char wav_4[] PROGMEM = "engage.wav";
static const char wav_5[] PROGMEM = "link.wav";
const char *wav_table[] =
{
wav_1,
wav_2,
wav_3,
wav_4,
wav_5
//etc..
};
void setup(){
Serial.begin(9600);
wav.speakerPin = 9;
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}else{ Serial.println("SD ok"); }
}
void loop(){
if(Serial.available()){
char wavFile[33];
switch(Serial.read()){
case 'P': strcpy_P(wavFile, wav_table[0]);
wav.play(wavFile);
break;
case 'd': strcpy_P(wavFile, wav_table[1]);
wav.play(wavFile);
break;
case 't': strcpy_P(wavFile, wav_table[3]);
wav.play(wavFile);
break;
//etc.. etc...
}
}
}

0
None
mrwenz21

6 months ago

how to increase the volume?

0
None
anviksha1

6 months ago

I am getting sd fail everytime. Plz if u could help me, I am using 4 gb sd card and arduino pro mini

0
None
abu3raby

6 months ago

hello
i need help for arduino mega with sd card play music no working but working in uno
i use #include <TMRpcm.h>
code


#include <SD.h> //include SD module library
#include <TMRpcm.h>
//include speaker control library
#define SD_ChipSelectPin 53 //define CS pin
TMRpcm tmrpcm; //crete an object for speaker library
void setup(){
tmrpcm.speakerPin = 9; //define speaker pin.
//you must use pin 9 of the Arduino Uno and Nano
//the library is using this pin
if (!SD.begin(SD_ChipSelectPin)) { //see if the card is present and can be initialized
return; //don't do anything more if not
}
tmrpcm.setVolume(6); //0 to 7. Set volume level
tmrpcm.play("1.wav"); //the sound file "1" will play each time the arduino powers up, or is reset
}
void loop(){}



i use pin 9 for speaker
//Please help my
1 reply
0
None
PankajS80

1 year ago

boss sound quality is soo bad what to do :

is it due to less voltage or due to less speed of arduino and liberary

2 replies
0
None
moemoussa12

10 months ago

hi,
I did everything as u want, but at the end i am connecting the pins to my earphone, and just hearing noise!!!!!!
I used the tone library,
I checked the ground for earphone also.
plzzzzzzzzzzzzzzzzzzz help

0
None
yagrawl

11 months ago

Hey, I followed your tutorial and it worked for mono. I was trying to make it work for stereo and I was wondering what the PCM conversion in the .wav converter for that should be. Thanks for the article and please let me know!

0
None
RokiR

Question 11 months ago

No SD fail, converted properly, but when i connect the speaker it plays beeping noise sound that glides up and down. Somebody can help?

1
None
Marvin14

Question 1 year ago

I still get the sd fail

0
None
yehya3

1 year ago

dude thank you so much it really worked, btw you better set the volume at 5 instead of 6 , but thank you so much

0
None
ua9901100

1 year ago

which other libraries can i use instead of tmrpcm(because it uses more space of memory) to play audio file in arduino uno?