Hey guys, need some help...trying to make a piezo buzzer louder, but the catch is that changing the voltage is not a solution (powered by a battery where increasing the voltage would mean increasing the the size of the powersource, I'm working on a very small project with not much room a larger power source).
My question is about differential driver, I read that you can effectively replicate double the amount of voltage going through a piezo buzzer by using a differential driver circuit, basically two voltage supplies, one whacks the piezo diaphragm in one direction and the other voltage whacks it back at the peak state, basically ping-ponging the piezo buzzer diaphragm back and forth for maximum diaphragm displacement, thus increasing volume.
How would I do this with code? I tried doing a tone/noTone thing between two pins and just adjusting the tone duration in milliseconds for each, but that didn't really work and would probably be endless trial and error. Ideas?
tone() won't do it because you can't control the polarity at any given instant. But if you can write your own program to write a 0 to one of the pins whenever you write a 1 to the other this will work.
That's easy to do if your program doesn't have to do anything else while making tone. For example, you can modify the basic Blink sketch to "blink" one output off whenever the opposite output is on, and vice-versa. And, speed-up the "blink" an audio rate to 1 or 2 kHz. But, you probably want to avoid using delay(), so base your program on the Blink Without Delay example.
P.S.
There might be a way to loop the tone() output pin back into an input to check it's instantaneous state, and write the opposite state to the other pin. But again, your program can't be doing anything else if it needs to react nearly instantaneously. ...Or, maybe you could use an interrupt to interrupt whatever else you're doing.