We need to connect a small speaker- a headphone one, to an Microchip Pic. I don't know whats the resistance of such speaker(it's very small) but I guess it's 8-ohm. (We are only using one headphone speaker, not both.)

I know the Pic can output 20mA in a port, so with 5V output and 20mA I have about 0.1W to use, which is good enough (Does not have to be audible to humans, this will be audio-coupled to a microphone).

Not knowing the speaker's impedance or current requirements, I was wondering if connecting them with a 300Ω resistor, directly to the mcu (with a dc blocking component), would produce something, or am I missing something?

Please don't advice an op-amp. I know about them, but am trying to avoid that, because I need a small signal and very small power draw.

• Headphones are often 16-32 ohms. Also, "class D amplifier". – Ignacio Vazquez-Abrams Oct 4 '13 at 8:29
• @IgnacioVazquez-Abrams class D is overkill for a headphone speaker. Overkill might be a understatement. – Passerby Oct 4 '13 at 8:37
• @Passerby: Sure, but if he's connecting it to a MCU anyways then he gets one for free. – Ignacio Vazquez-Abrams Oct 4 '13 at 8:38
• 300 ohm and a series decoupling capacitor would work ok if you are just feeding tones - don't expect audio unless you are PWM modulating the logic signal from the MCU. – Andy aka Oct 4 '13 at 8:39
• The 300R seems like a bad idea, most of your tiny output power will end up there and not in the headphone? – pjc50 Oct 4 '13 at 8:41

While this is a less authoritative answer than I prefer to give, frankly, yes, that should work.

There are many projects where a speaker is directly connected to a microcontroller through just a resistor. The Arduino Tone library and Tutorial is one such example. The Arduino uses an Atmel ATMega328 (or similar), with a similar current limit (40mA, with voltage droop). The example/recommended setup is an 8Ω speaker connected with an 100Ω resistor. While speaker Impedance is not the same type of Ohms as DC Resistance, the combination of greater impedance of your headphone speaker (Typically 16-32Ω) and higher limiting resistor (300Ω as you mentioned) should be enough to both produce sound and protect the Pic's output pin.

Most often, a DC blocking capacitor is not needed in these limited situations.

Then again, this is my educated guess.

The other option is using a single npn transistor for the speaker. This might be sufficient if a direct connection is not.

• Thanks a lot for your help ! but with 300 ohm resistor, and a 16 ohm speaker, the resistor takes all the power for himself, isnt it ? and about the transistor, because some restriction ,we didnt wanted to put one, but if you have some circuit diagram that uses only 1 transistor,not too many things around him, i will be happy to hear. thanks again.] – Curnelious Oct 4 '13 at 9:07
• @Curnelious: Connecting the speaker and filter across complementary outputs will increase the output power. – Ignacio Vazquez-Abrams Oct 4 '13 at 9:12
• i dont get you. you say i should output the signal from 3 ports of the mcu, to the speaker ? – Curnelious Oct 4 '13 at 9:21
• Use 2 outputs. When one outputs a high the other outputs a low, and vice versa. – Ignacio Vazquez-Abrams Oct 4 '13 at 9:31
• @Curnelious it shouldn't. And you could adjust the resistor as needed (a trim pot can be used for testing). – Passerby Oct 4 '13 at 9:45