
Bryan Duxbury offers a tip to get more volume from a weak MCU output pin.
This may be an obvious trick to some, but I just did a short writeup on a really simple way to get more volume out of a speaker attached directly to a weak microcontroller pin – like those on the Arduino – without any complicated audio amplifier ICs. If all you’re doing is playing square waves, you can use nothing but one transistor to get the maximum volume! Now that buzzer in your project can *really* annoy your cat.
Via the contact form.

simple and works, why didn’t i think of that?
Or use a open-collector instead of a emitter-follower…
*an
Should put a capacitor in series with the the speaker to prevent DC current. Something in the balpark of 200 uF should work fine.
Perhaps you can boost the speaker volume without a transistor by using two pins connected across the speaker and toggling the pins in complement (when one pin is high the other is low). This causes larger movement in the speaker’s diaphragm.