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 124Next »
sideswipe267416 hours ago

Hi Husham,

This worked great! I was wondering if there is a way to use one button to play each wav sound / music in sequence. Like how a toy works where you hit a button and you get a different sound.

Thanks!

ParkerO11 days ago

Can you give a list of more specific items? For example: 10-wires. What type of wires? 4-Bread Board. How big? there are different sizes for it. or put in a link for each item.

Hi guys,

I want to play a audio file in a bluetooth headphone with arduino. Do you know how can I do this?

RenatoL made it!1 month ago

Guys I discovered the problem with Arduino 1.6.4 software version, just add a line with "#include <SPI.h>" after the line "#include <TMRpcm.h>", Now its working with 1.6.4 version and with ARDUINO UNO board.

photo 01.JPG
RenatoL1 month ago

I made it and works well with Arduino 1.0.3 software version, but if I try to use the same code with Arduino 1.6.4 software version I have several problems with Error compiling.

voltman2 months ago

I can't compile the sketch I get

TMRpcm.h: No such file or directory, yet the library is there.

safayeta voltman2 months ago

use arduino 1.0.3 software.. Newer version does not support this library

Husham Samir (author)  voltman2 months ago

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

i also got a compile error:

TMRpcm.h: was not declared in this scope

But i have installed the library

speakerbock2 months ago

Hey wondering if you can help me, i have tried building this but the audio only plays as long as the button is held down, would you have any idea as to whats i have done wrong, thanks !

RameshK52 months ago
I did this project using an Arduino Uno and 8 Ohm speaker without the transistor and the sound volume was fair.

Thanks For Sharing It
AamirA1 RameshK52 months ago

hi ramesh, can you please tell me the parts you used for this project,code and the wiring diagram.please, because i also want to make this project with arduino uno

what is the parts of project using Arduino Uno??
and what is the Connection method??

AamirA12 months ago

can this project play voices

djoker072 months ago

can i use another transistor aside from the BC546B NPN???

thank you

SteveK82 months ago

Hi Husham,

Thanks for sharing your great work!

I'm having a problem with initializing the sd card using 'SD.begin()'. I've formatted the card with FAT32 AND all the connections seems to be ok to me.

What could be the problem? Can you shed a light please?

AdieV2 months ago

Excuse me sir, i want to ask you about
how much voltage in your input ?
what is the spesificaton of your speaker?
i want to make a project same as yours..:D
thanks

Husham Samir (author)  AdieV2 months ago

5 Volt

oke thankyou sir
how can i check my push button works or not with my arduino program?
can you help me..

mfreire43 months 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?

Husham Samir (author)  mfreire43 months ago

Hi,

first of all ,make sure that you connect the transistor correctly.

if yes ,then try to amplify the wav file using the software.

PenguinM3 months ago

Hi, first off great instructions. I am working with the same library and your converted files were very helpful. For some reason, the files you have converted work perfectly, but when I try to convert my own, which include vocals, I get jsut static. I have used Audacity to convert them, and converted your files using the same method, but only yours seem to work. Do you have any advice on how I can get my files converted properly?

Husham Samir (author)  PenguinM3 months ago

Hi,maybe the software you used not convert it probably , try to use the same software I used (WAV sample converter) and set it as below

Samples Per second(Hz):16000

Channel :Mono
Bits PerSample: 8

I hope it will work.

Meka283 months 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?

BasS23 months 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.

tonini463 months ago

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

goldenshuttle4 months ago

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 )

nvilocity4 months ago
Great project!! Good discription and explanation. Your awsome... Thanks
A.Ward887 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.
kpdavis7 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)  kpdavis5 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
djdeeno7 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)  djdeeno5 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

1-40 of 124Next »