Instructables
loading
loading
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 102Next »
mfreire44 days ago

I did the same as his scheme . But the speaker sound is very low.

I used the speaker 0,25W 8ohm and the sound remains low.

How do I put the loudest sound?

Meka289 days ago

Dear, this is a nice piece of work!

Though, I tried to apply it on a BareConductive Touch Board, but couldn't successfully upload the WavSW_ino file: "Error Compiling" message.

Any idea if this could work on such board please?

BasS211 days ago

This is almost perfect for what i want to create:)

I want a slight modification: because I can only use two wires for the 5 buttons I have to create a switchboard like this (my electronics skills are the worst :( ).

Is it possible to digitize this output so the Arduino knows what key(s) are pressed? Do you have an example of how i could try and make this work...

You could use an I2C bus exapander like a PCF8574. Take a look at this tutorial: http://garagelab.com/profiles/blogs/tutorial-arduino-i-o-port-expander-with-pcf8574

Very helpfull, thanks!

I'm currently looking into this with R-2R ladder setup:

http://tronixstuff.com/2012/02/29/tutorial-analog-...

Yes, the R ladder setup is an easier solution I guess.

tonini4614 days ago

Does this library work with the Intel Galileo Boards Gen 1 and 2?

Hi Husham. Great project, I was doing a speaking distance meter, using WTV020 which is also SD based sound file player. But WTV020 has so many issues and decided to dump it. I probably prefer to go for SD direct, can it speak different distance say usig If-else statement ? did you try it ?

Hey goldenshuttle, I also want to make same project which you mentioned. You said that there are some problem about WTV020. What kind of problem did you mention? ( I searched a lot, but everyone who used WTV020 is ok )

nvilocity1 month ago
Great project!! Good discription and explanation. Your awsome... Thanks
A.Ward884 months ago
Could one use piezoelectric sensors to play the sound file?

I guess you meant that you could use a piezo instead of a coil spealer.

So, did you get it to work? Does it sounds good?

Yep, I have the same idea, arduino codes are essentially if this happens, then do this. You can trigger them with distance, alcohol sensors, temperature, light, literally anything.
kpdavis4 months ago

We got this going without much trouble at all. Now we are trying to run the audio to a set of PC desktop speakers via a 3.5mm audio plug. We get a lot of hum. I see that one suggestion is adding a capacitor, so we will try that. But also saw the suggestion of just taking the transistor out. We can give that a try also. Just not sure what should be coming out of one of those 3.5mm audio plugs. It must be somewhat standard. If there are other suggestions, let me know.

Husham Samir (author)  kpdavis2 months ago

Hi,

I believe the best solution to remove noise issue by using ceramic capacitor (code 104) .

We took the transistor out and ran the audio from the arduino to the powered speakers. We also improved the grounding. that make it much better.

thanks for the reply.

Kriss
djdeeno4 months ago

Hi

What a great sampler is this, i gonna make also a sampler.

I have a little question about this one, is it poisable to make it for stereo line out? so without a speaker but left right line output? please let me know.

Ps is there a arduino topic on the forum there?

Kind regard from Amsterdam

Marcel

Husham Samir (author)  djdeeno2 months ago

Hi,

if you check the headphone jack ,The tip is the left channel,the ring is the right channel, and the sleeve is ground ,so if you short left and right channel ,you will get sound in both speaker but in mono mode.

if you need better quality and stereo mode ,below link might help you.

http://playground.arduino.cc/SmartWAV/SmartWAV

safayeta4 months ago

I am using BC547 transistor and 8 ohm 0.5 watt speaker
The sound is vary low
in your video the sound is quite high
how can i increase the sound.. Thanks

Husham Samir (author)  safayeta2 months ago

Hi ,

Try to find a software to increase the volume of the sound file ,then test t again in the circuit

varuna13 months ago

hi can the output of a ping sensor be made into a voice output

Hi I'm very interested in this project but when i have installed the library all examples haven't been correct for the ide because it told me that i havent installed the library but i have done it

RowanD13 months ago

Hello! This instructable is awesome, and I appreciate your writing it. I am, however, having major issues getting my audio files to play. I have gotten the whole set up working using the sample files, but I cannot get mine to play.

I have converted the files to 8bit 16 kHz mono wav files, and have tried multiple attempts with naming conventions with no luck. The files play fine on my computer (degraded in quality somewhat due to the 8bit 16 kHz factor, but certainly more recognizable the fuzz I'm getting out of the speaker in my set up).

Thanks for any help anyone could give me in this. I have multiple DAWs and am capable of manipulating the audio files however is necessary, but I'm at a loss of what to try.

ko.ten.75 months ago

i want to use with atmega8.

please help me!!!!!!!!!

err.png
alexr10 ko.ten.74 months ago

perhaps it is cause atmega328 has 4x flash memory of the atmega8, see how big the hex executable is. you may need a chip with more memory

KUPOV4 months ago

Hi, very nice and useful instructable, but my do not work at all. I use 0,2 W 8 ohm speaker. My code work properly. I thought that it is something with sd card, but when I wrote code for saving data it worked. Do you have any idea what may be cause of problem?

DSC_0036.JPG
LiamB2 KUPOV4 months ago

For me, I ended up getting rid of the buttons to make it simpler, and editing the code given to get rid of the buttons.

Mine also didn't work, until I realized that I was playing the sound every single time in the loop, which will just repeat the first couple miliseconds forever. Make sure you are playing the file only once, not every loop.

safayeta5 months ago

I have tried this project. But after compiling the code there is an error

"In file included from WavSW_ino.ino:3:0:

C:\Users\Uaer\Documents\Arduino\libraries\TMRpcm/TMRpcm.h:17:19: fatal error: SdFat.h: No such file or directory

#include <SdFat.h>"

Please Help I need to fix this.
Thank You
my email address is safayetahmed.s@gmail.com
please if you can send me your TMRpcm library file it will be helpful.

NoahC2 safayeta4 months ago

just comment out "#include <SdFat.h>" in the begining of TMRpcm.h and TMRpcm.cpp :)

safayeta NoahC24 months ago

Problem Solved.. I used arduino 1.0.3...

Husham Samir (author)  safayeta5 months ago

the library I used SD.h Not SdFat.h and already included in arduino sketch so no need to donload the library.

hi Husham Samir may you explain again what to do to make this solved?

thank's :]

emgeiger5 months ago

I can't run the audio clip editor you suggested because I'm running mac OSX, could you convert a file for me? (link to download file) : https://www.freesound.org/people/CommanderDerp/sounds/167921/

Use Audacity, it does what you want and is compiled for Mac OS X as well. However, you may possibly prefer going to Windows, the Mac doesn't have what you need.

I am facing the same problem. I have downloaded the SdFat.h and included in the TMRpcm library. but it still show errors.

Husham Samir (author)  nasrul.fahmi.315 months ago

the library I used SD.h Not SdFat.h and already included in arduino sketch so no need to donload the library.

i didnt understand your explanation the error is still there may you explain again what can i do ?

thanks alot :]

monolitico4 months ago

Hello Husham. Thank you for this tutorial.

I also found that the files are missing, and also find that it depends on which language is instructables.com. If you watch this tutorial on english version, the files are there, but for example, in the spanish version I can't find them.

Check the difference:

http://www.instructables.com/id/Playing-Wave-file-...

http://www.instructables.com/id/Playing-Wave-file-...

i have this error can you help me

basic.ino:4:71: fatal error: TMRpcm.h: No such file or directory
compilation terminated.

thanks

Husham Samir (author)  mohammad.habib.12916 months ago

Hi

this error telling you that you didn't install theTMRpcm library in the right location.

1-40 of 102Next »