I’ve been planning out a project with the April dev board, and would like to be able to play simple sounds (say, a sine or square wave at 440 Hz, for example). I’m not very familiar with electronic components in general (more of a software person) and so I was wondering:
- What materials would I need/want to hook up a small, simple speaker to my board?
- What sort of a speaker should I even get?
Hopefully someone has some experience doing this, even if not with an April board (or maybe not even with an Electric Imp)? I’ve been looking at the page on using samplers and fixed-frequency DACs but it only discusses the software side (as far as I can tell). Being able to output a signal is great but I know there are issues with speakers like having to match impedance and suchlike?
To drive a speaker, you would need a speaker amplifier - something like this would work:
…which you’d put between the imp DAC pin and your speaker.
I’ve done simple audio output just like that with an April, including WAV files actually within my squirrel code for simplicity (you’d need to encode them as strings)
If you don’t need it to be very loud, use a piezoelectric speaker:
Basically the same thing on the Imp as they do with the Arduino.
No amp needed.
Thank you to both of you for your advice!
A quick search on Amazon showed piezoelectric buzzers that mainly claim to have a resonant frequency of 3900 +/- 500 Hz (examples here), and yet searching YouTube turned up videos of people using them to play melodies that spanned more than that range (at least more than an octave, while this range is rather less than an octave). Can all the buzzers I saw likely be driven passably at other frequencies, and just respond much more strongly in the described range?
Someone here might be more experienced at audio stuff … This is a bit out of my forte.
Since the prices are so cheap, if I were in your shoes, I would buy a few different ones and experiment. I would expect different sound qualities and tones among the various buzzers, or speakers as I called them. ‘Buzzers’ seem to be the more common term.
What you show with your Amazon example is a tone alarm. You apply a voltage and it emits one fixed tone. I’m thinking you need a piezoelectric buzzer that is only the piezo element, like this:
With that ceramic buzzer, you use PWM to drive it and create the various of frequency.
This website looks like they have a lot of information on how they work:
You could contact them and describe what you are trying to do. Maybe they have a solution like Hugo mentioned where you use a micro amplifier with a mini magnetic (traditional) speaker.
… and then we’re back to what Hugo mentioned …
That might be the best way after all.