Instructables
Picture of Playing Wave file using arduino
This is a simple circuit to play wav files using arduino Nano V3.0 ,it consist from 4 buttons ,each one play specific wav file loaded to SD card.
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts

Picture of Parts
Funduino Nano V3.JPG
Funduino Nano V3 1.JPG
SD.JPG
SD1.JPG
1- Arduino Nano V3.0 (I used the chines version called Funduino Nano).
2- SD card Module.
3- SD card.
4- Bread Board.
5- four push Button .
6- four 22K resistors.
7- one 4.7K resistor.
8- BC546B NPN transistor.
9- Speaker.
10- wires.

Step 2: Prepare your SD card

Picture of Prepare your SD card
Format.png
Wav Sample Converter.png
1- Format SD card and make sure the setting as attached picture.
2- Convert your music to .WAV files and make sure the below:
-Samples Per second(Hz):16000
-Channel :Mono
- Bits Per Sample: 8
I use Wav Sample rate converter software (picture attached).
3- Wave files samples attached.

Step 3: Circuit Digram

Picture of Circuit Digram

Step 4: Source Code

Picture of Source Code
1-Before writing the code you need to install TMRpcm library from below link:
https://github.com/TMRh20/TMRpcm/wiki
all information how to install and use the library included in the website .

2- Download the attached WavSW_ino.zip file and open it with arduino sketch ,I tried to copy and paste the Source Code from arduino sketch to instructable but for some reason the text convert to rubbish.



WavSW_ino.zip887 bytes
1-40 of 58Next »

Really a nice project!

But I have the same problem others had as well: the zip-file is nowhere in sight.

Husham Samir (author)  twilightzone4213 minutes ago

Hi

yes ,for some people they can not find the ZIP file on there browser ,I don't know ,it looks like there is a bug in the website ,so you can send me your email in order to send you the file.

Lndjetyesterday

sir im using other clone boards and nano v3.0 with 8 ohms 0.5w speaker

i trace the schematics of those two and locate the PWMs and SPI
and try the sd samples to verify my connection and result is okay the program can locate the files in sd

but when i try the codes of yours

in nano the micro controller is not responding and no output on speaker

in the clone result is no output on speaker

thanks sir this work of is a big part of in our project

Husham Samir (author)  Lndjet23 hours ago

Hi,

When you verify the code in the sketch ,did you get any error ??

hi sir,
there no error sir. and i try your program with the sd cardinfo example. in same sketch..

when i run the serial monitor the data in sd is found but there's no audio output.

Husham Samir (author)  Lndjet17 minutes ago

Hi,

try to connect headphone directly to PWM pin and check .

make sure the names of wav files in the SD card is the same in the code and don't put it inside folder

also make sure that the baud rate is 9600 ,if you check the comments below you will find that some people get issue when they change the baud rate.

I hope these things will help you.

nodoubtman7 days ago

Thank you so much! :)

Thanks for the great Instructable. I managed to get it working earlier today and am running the output in to a portable speaker... It sounds great when the audio is coming out but when it is waiting to be triggered (as a few other people have mentioned) it is really noisy. I have tried a capacitor (like you suggested) between pin 9 and the input for the speaker but it doesn't seem to do anything. :-/ Do you or does anyone else on here have any suggestions?

Husham Samir (author)  antdickinson15 days ago

Sorry for that but I have no idea how to solve this issue .

Ok, no problem. I am going to keep on experimenting with caps and possibly slightly different wiring to the switches. Thanks again for a good instructable. :)

Good day sir.. Does it work with other boards of arduino? 'coz we dont have arduino nano v3.0 :)

Husham Samir (author)  cris.olayvar3015 days ago

yes ,it work with other arduino board but the pins connection will not be the same.

DoctorWoo1 month ago
Sorry if this was already addressed, but could you just replace the speaker in here with a headphone jack and use a set of headphones or a speaker with the correct jack size?
peterj21 month ago

Been trying for hours now to get the stereo output to work on an Arduino Mega, is there a diagram somewhere where all the pins and connections are described for the Mega

hi nice work sir ,,,, how cn you make this polyphonic :DD im currently working on my electronic drum but i couldnt play two to three drums at a time ,, is there a way that i could make it polyphonic .

i really need your help :D please pm me on facebook www.facebook.com/polylights

thank you

n1cod3mus2 months ago

Hi, thanks for the instructable really good works great however, I have an issue with volume, its not very loud, I am using an amplifier module and a 4W speaker, its a tiny speaker 30mm x 40mm. it has to be small to fit in the device I want to put it in.

any ideas how I can get a reasonable amount of volume out of a small speak or one that would fit in a 35mm high space?

its this speaker

http://www.ebay.co.uk/itm/390813570381?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

TDW91 n1cod3mus2 months ago

Hi, I'm using this speaker for a similar project and I was wondering, what are you using as an amplifier module?

Thanks in advance!

n1cod3mus TDW912 months ago

it was an LM386

ok turns out my Wav files had low volume, upped them in a wav editior seems much better.

orgasmotron2 months ago

hello , you've made a great project , i have a question about it , will it be hard

to loop the sound wave when you press one of the 4 button

pain963 months ago

Hi. First of all, thanks for the tutorial because you did a very good work here but sadly, i can't get it work :( I'm using an Arduino Uno with an ethernet shield which has a micro-sd slot too. I downloaded your code and uploaded it on arduino, but when i connect the speakers to pin 9 and GND it just makes a noise, without playing anything.
Thank you for your attention, I hope you could help me.

Husham Samir (author)  pain963 months ago

Hi

first of all make sure everything connected correctly .

if you check below comment ,one of them get the same problem you have ,his name David Piccinini and he solved the problem by changing the communication speed baud rate to 9600

I hope it will work.

Good luck

Hi, thanks for the answer.

Actually, i didn't have to connect anything, cause i just put my ethernet shield on my arduino, put in the micro sd (class 5 type SDHC) with your files, connected the speaker (without amplifier, just to see if it worked) and upload your code. The baud rate was already at 9600, and i stil can't figure it out. I'm starting to think that my ethernet shield is a scam. If you have any further information, that would be appreciated. Thanks a lot.

Husham Samir (author)  pain963 months ago

Hi

try to check the SD card example .

go to File ----Example-----SD -----card info

verify then upload

open the serial monitor and check .

if you could not read the SD then read below article ,you may find something useful.

http://arduino.cc/en/Reference/SDCardNotes

thanks for this comment, it helped me out, I thought I had done something wrong with my wiring and this proved I had it right.

so now I need to check everything else lol

vkaushik13 months ago

helpful tutorial indeed!!! I used a MEGA 2560 board, the output from the board is given to the speaker( 8 ohm 5W) through a easily available transistor 2N2222. I hooked the output pin from arduino to the base through a 100 ohm resistor , +5v to collector and the emitter to speaker's one pin. but still the audio output is very feeble. IS there any way to increase the sound rather than going for an conventional amplifiers???

Thanks in advance.

Husham Samir (author)  vkaushik13 months ago

Hi

if you use 5W speaker ,I believe you need to use Amplifier but before that try use ( 0.2 W speaker) ,you might get your requirement.

kvenkatesan13 months ago

Its cool. worked great. the audio was too low and so i used LM386 amplifier now all get is a humming noise. what could be the solution?

Thanks!

Husham Samir (author)  kvenkatesan13 months ago

Hi

try to connect ceramic capacitor (code 104 or 103) between the output from arduino and the input of LM386 ,this capacitor should filter the DC voltage that cause the noise.

thank you.

mrnateytatey3 months ago

Can you run the circut with out a transistor and say connect it to a amplifier would that work?

mrnateytatey3 months ago

I keep getting this error PLEASE help asap.

I want to get this project done a quick as possibal

TMRpcm error.PNG
Husham Samir (author)  mrnateytatey3 months ago

hi first of all make sure that the TMRpcm library installed in correct folder (libraries).

if you already install it and you get the same problem do the below:

1-Rename the folder TMRpcm libraries to TMRpcm1.

2-Enter inside TMRpcm1 folder you will find another folder called TMRpcm

3- copy TMRpcm folder and paste it in arduino libraries.

4- delete TMRpcm1 folder

5- Restart your IDE and check ,it should work.

Thanks lots,the fix worked. I cant believe i diddent think of that

Husham Samir (author)  mrnateytatey3 months ago

I'm glad to hear that.

I changed the TMRpcm tmrpcm; to Tmrpcm audio; but to no avail i diddent get it working even after that change

mrnateytatey3 months ago

Can you run the circut with out a transistor and say connect it to a amplifier would that work?

Husham Samir (author)  mrnateytatey3 months ago

try to connect it to headphone or smaller speaker first if you don't want to use transistor.

amplifier will work but if you get loud noisy sound ,you might add a ceramic capacitor in the way to solve this problem

mr79194 months ago

can we use sd card shield like https://www.sparkfun.com/products/9802

Husham Samir (author)  mr79194 months ago

hi

yes you can but you have to change chip select in the code.

Check the link below:

http://arduino.cc/en/Reference/SDCardNotes

1-40 of 58Next »