Audio Player Using Arduino With Micro SD Card

98,641

85

135

Introduction: Audio Player Using Arduino With Micro SD Card

About: i believe to help people and share my knowledge i always want to build creative thing some of them for learning and some of them is very useful.

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.

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".

mirror :- https://codeload.github.com/vishalsoniindia/Audio...

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.

https://github.com/vishalsoniindia/Audio-Player-Us...

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

  • Battery Powered Contest

    Battery Powered Contest
  • Plywood Challenge

    Plywood Challenge
  • Plastic Contest

    Plastic Contest

135 Discussions

0
Avali123
Avali123

Question 3 days ago on Step 7

I got everything exactly the same, copied the code, added the library and checked if the sd card worked, and it does and yet I cant get it to work, what am I doing wrong ?

0
yodizf
yodizf

2 months ago

Brother...
how to make an SD card for the Murottal Al Quran speaker

0
vishalsoniindia
vishalsoniindia

Reply 2 months ago

Very easy...
Play one song from my tutorial and then as same as you can play many songs

0
jonatanko666
jonatanko666

4 months ago on Step 7

i try to make SD card file read on button press and LED blink with delay ....i want to make cosplay laster gun on shot push make laser sound and light on button hold make stronger charging laser sound and im new i try to make some code but almost always have some errors cause im newbe in this and i know i forgot add library or something to make works as shuld and i dont know where to begin and cant find any similar schematic or manual on web any ideas ?

0
RyuWhite
RyuWhite

Question 4 months ago

I've been done this with $1 speaker. Sound quality was pretty bad. Any recommendations for speakers?

0
PrinceY9
PrinceY9

Question 10 months ago

I have done everything right but the voice is not at all coming from the speaker

0
olivertaylorrrr
olivertaylorrrr

Question 1 year ago

Does the micro SD card have to be a certain size? I bought a 64gb micro SD and i put everything together properly (supposedly) and it still wont work.

0
aswtang
aswtang

Question 1 year 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
ShivaS68
ShivaS68

1 year 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

0
tamias47
tamias47

Reply 1 year 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
LiutaurasM
LiutaurasM

Reply 1 year 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
havindu dulaj
havindu dulaj

1 year ago on Step 6

It worked very well!!! THANK YOU very much!

0
mrwenz21
mrwenz21

1 year ago

how to increase the volume?

0
anviksha1
anviksha1

1 year 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
abu3raby
abu3raby

1 year 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
0
abu3raby
abu3raby

Reply 1 year ago

help

Arduino-SD-Card-Module-Circuit-Schematics-Tutorial.png
0
PankajS80
PankajS80

2 years 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

0
RaviK352
RaviK352

Reply 1 year ago

Could you please explain