Blocking capacitor? Driving 8 ohm .5 watt speaker with microcontroller

capacitormicrocontrollerspeakers

I'm reading Make: AVR Programming. The next project wants me to try to drive an 8 ohm speaker with a pin from the microcontroller.

I'm no EE, but I do know that 8 ohms is not a lot of resistance, and it seems like we're going to run into problems running too much current through the microcontroller pin.

The book's solution is to use a "blocking capacitor". For some reason, I'm still a bit skeptical this is safe for my microcontroller. There are no resistors anywhere in sight. Here is the page from the book:

Blocking capacitor diagram

Question: if I don't care about sound quality, is this circuit safe for my microcontroller? The maximum current is supposed to be 40mA per pin.

Best Answer

Whoever wrote that page is criminally wrong. The blocking capacitor is only an open to DC. The AC current will still be much higher than the AVR's absolute maximum. As a minimum, put a push pull buffer between the micro and speaker. I would rather see a low side switch.