When I started with my CastDuino project I knew I would need something as an alarm, so our workers would know about lunch brakes. Back then, I was thinking about using an mp3 shield, but when buying it, I found out it uses the Arduino as it's cpu to play MP3's leaving no place at all for doing anything else. Why not use a cheap MP3 player and use the Arduino for triggering it. I bought 2 at ebay (yep real cheap). Tom helped me out, connecting it to my Arduino. BUT ... The thing just starts playing what ever is on the card and keeps repeating it over and over. Mmmm, when you only need one sample to be played and you know the length of your sample, it ain't hard to get it right.
So I decided to try something with an SD card and an audio library, which seems to work out quiet well actually. Now, when you say: "but now you're off to square one, because you still have an ATMEGA used specially for playing sound.", you' re right. But this time I can use I2C to trigger all kinds of things. So that's perfect for my own shield AND I probably can combine the code with the one I made for the CastDuino OUTPUT, which would be nice, because ... after all, it is ... output.
Sometimes you just can't do without some theory. When I wanted to know, why I would need a capacitor and resistors before connecting speakers to an Arduino, I had to do some reading myself. Finally I did understand why (took me some time to find a site explaining simply and correct, what is happening when you connect speakers. I'll try to do the same, short and simple.
When you connect a device to your Arduino, like a speaker you create a short (well sort of). When you use a wire, you'll get sparks and
I = V/R or amps = volts/ohms
Now when your ohms become 0, well your amps become indefinitely high, meaning *explosion* . When you keep that in mind and you know speakers come in 2,4 or 8 ohms of resistance, you'll surly understand that if your Arduino can only handle a max of 40 mA on every pin, this means 0,040 A = 3,3V/ohms or 3.3V/ 0,040 = 82 ohm.
But if your speaker is only 2 ohms or 3,3V / 2 ohms = 1,65 A which is way to high even 8 ohms gives you 0,410 A or 410 mA. Ten times what your Arduino can stand. The solution? add more resistance in series with the speaker, like a 100 ohm resistor => 3,3V / (100 + 2) ohm = 0,032 A or 32mA and that is perfect.
For now, have a look at http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio (the original project page) REMEMBER, YOUR ARDUINO MUST RUN ON 3,3V OR USE A LEVEL CONVERSION CIRCUITS FROM 5V to 3,3V FOR THE SD-CARD (OR YOU'LL FRY IT)
The library and examples aren't mine, you can download everything from: SimpleSDAudio
BareBone Arduino .wav player
|Selection||File type icon||File name||Description||Size||Revision||Time||User|