Biasing Arduino Output to 0v

Hi All,

I have been experimenting with outputting sound directly from my arduino using PWM. I am able to play an 8000 hz sound to an earbud headphone by connecting the 2.5mm socket directly to the ground and the output pin.

What I would like to do is output +- 2.5v rather than 0 - 5v as I understand this will drive the headphones (or a speaker) as they are intended to be driven. My understanding is that the speaker will only oscillate through half of it's travel if I use only positive voltages. (Am I being pedantic about this?)

I tried a simple voltage divider for the earth to turn the 5v supply into a 2.5v supply but it reduced the volume of the headphones significantly. I can only assume it is because my resistors were too large. I am concerned that if I put small resistors in the voltage divider I will waste power. (Not sure if this is a valid concern). Sadly I also managed to blow up my arduino during these experiments. I am currently waiting on an ISP to load a bootloader on a new chip. How can I protect my arduino from this while experimenting. Would a series of diodes on the output pins stop negative voltage? Is there a way to limit voltage/ current getting back to the arduino without significant tradeoffs?

I was considering the use of an operational amplifier to both boost the signal and bias it around 0v but it seems that the gain of Op amps is typically very high which would be excessive for my needs.

I guess I am trying to work out what the ideal circuit to drive headphones or a speaker would be. At the very least, what components should it contain?

Kind Regards,

Ben

Am I being pedantic about this?

Only slightly. But there's an easy way to do what you want to do! Just put a capacitor in series with the Arduino's output pin. This will act as a "DC blocking capacitor". An electrolytic capacitor with a value of a few microFarads should be OK. Connect the positive side of the capacitor to the Arduino pin and the negative end to the earpiece.

If you want to build a proper headphone or speaker amplifier, you could use a chip called the LM386. It's an 8-pin audio amplifier chip.

Thanks,

That looks good. I will have a go with that and see what happens.

After reading a couple of posts on DC Blocking Capacitors I have a sense of what is going on with them.

Kind Regards,

Ben