Arduino Forum

Using Arduino => Audio => Topic started by: androidboy on Feb 15, 2011, 12:50 pm

Title: Arduino Speaker - how to do it?
Post by: androidboy on Feb 15, 2011, 12:50 pm
newbie here...working on a project with an accelerometer, which involves movement and sound. Basically I will include the arduino in a device that, when thrown up in the air, will make a sound. I think I can figure out how to get the values from the accelerometer and relate them to particular sounds in the code. My questions: HOW DO I connect the speaker (should it be a piezo speaker? what size/specifications? Can it play .wav and .mp3 files, or just a particular type of audio files?). Thanks...
Title: Re: Arduino Speaker - how to do it?
Post by: robtillaart on Feb 15, 2011, 01:30 pm
An Arduino can normally only play WAV or MP3 when using additional hardware, a shield or so.

For a piezo you might start here - http://www.arduino.cc/en/Tutorial/PlayMelody

Quote
Basically I will include the arduino in a device that, when thrown up in the air, will make a sound.

Maybe add some LED's too, different colors indicating diff speeds.
Title: Re: Arduino Speaker - how to do it?
Post by: mowcius on Feb 15, 2011, 01:31 pm
Does it need to play audio or will a beep suffice?

The tone library can do a beep and it could be set to trigger based on a value from the accelerometer.

If you really need it to play audio then you will need some kind of audio board/shield.
Title: Re: Arduino Speaker - how to do it?
Post by: androidboy on Feb 15, 2011, 01:36 pm
it will play pre-recoreded human voices. I can convert the audio files to any format. I thought piezo speakers could play more than just beeps...?
Title: Re: Arduino Speaker - how to do it?
Post by: mowcius on Feb 15, 2011, 02:12 pm
Quote
I thought piezo speakers could play more than just beeps...?

Well they can but you need some kind of chip to process this audio you want it to play. Without external hardware the arduino can only really get a piezo to play beeps.
Title: Re: Arduino Speaker - how to do it?
Post by: Grumpy_Mike on Feb 15, 2011, 04:20 pm
There is not enough memory in the arduino to hold any sort of sound file. So you have to have an SD card to hold the data. Also there is no digital to analogue converter on the arduino so you have to have an external one. The two extra features can be found in a wave shield which also includes an audio amplifier to drive a speaker. This is typical:-
www.ladyada.net/make/waveshield (http://www.ladyada.net/make/waveshield)
Title: Re: Arduino Speaker - how to do it?
Post by: WilliamK Govinda on Feb 15, 2011, 05:53 pm
Gesh, I just created a 6 voice Drum-Machine using the Arduino 2009 (ATmega328) ;-)

Check this out:

http://www.arduino.cc/playground/Code/PCMAudio

For 8khz it will do just fine for your project.

Wk