Go Down

Topic: Driving a speaker with an Arduino pin... (Read 781 times) previous topic - next topic


I want to drive a little speaker with an Arduino pin, is there anything I need to worry about?

I assume I need some sort of limiting resistor, how would I calculate the value?

The 'speaker' is actually from a headphone. A quick test shows it makes quite a loud beep when driven by an Arduino pin.

I measured the resistance as 40 Ohms with my multimeter (although that might not mean much on a coil).
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)


Make the resistor keep the total current below 40mA and couple it with a capacitor about 1uF non polerised.


Sounds very similar to common "magnetic" transducers used in place of piezos, eg

They show a driver ckt there, but as GM says, you can probably use an Arduino pin
directly. I've used these quite a lot on PIC I/O pins, connected via a 10-uF cap, and
reverse diode across the transducer pins. No series-R.

Since they are "coils", if you use an NPN inverter as shown in the d/s, you need to
be certain the signal never sits high constantly, or else you'll be driving a continuous
current through the device - I also use that same ckt, but with a 10uF cap driving
the NPN base.


150 ohms or above will protect the Arduino pin in most circumstances - limits current to 33mA which is
just within spec.

And the capacitor mentioned (which can be higher in value for more bass response BTW) prevents DC
offset current through the speaker which will distort the cone's resting position.
[ I won't respond to messages, use the forum please ]


One thing I don't get...

Ideally a speaker should be driven backwards as well as forwards (ie. negative voltage across it) so the other wire on the speaker should really be at 2.5V.

Is that possible with a couple of components? Would it make much difference to sound quality? (I might try playing back an audio sample on it to see how it sounds)
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)


   You might be better off using an op-amp as a buffer, haven't tried any of the op-amp headphone driver circuits yet, but keep meaning to.

Duane B


The simple ckts described are good for "buzzing", not for audio quality. If you
want the latter, the minimum cktry will be an LM386 amplifier [not the best sound
quality], being fed from an Arduino PWM channel through a 2-stage low-pass filter
with maybe 10-Khz 6db cutoff.

And then you use high-freq PWM, at least 100 Khz and 7-bit resolution, and modulate
its duty-cycle using your audio waveform. Then, it might sound like something other
than buzzing.


My goto amplifier, there maybe better variations with filters as suggested by Fungus but this works well for me. Most of my breadboards have one at the end because once you start adding sound to projects you don't stop. The circuit is also small enough to leave on the breadboard when you are finished so its ready for the next project -


Duane B


Go Up