Pages: [1]   Go Down
Author Topic: Arduino Speaker - how to do it?  (Read 8397 times)
0 Members and 1 Guest are viewing this topic.
Ukraine
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Ukraine
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...?
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Brazil
Offline Offline
God Member
*****
Karma: 3
Posts: 626
Beat707.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pages: [1]   Go Up
Jump to: