Introduction: How to Make an Arduino Driven Piezo LOUD

About: just have to figure out how all these things go together....
Hey all! I struggled with making a loud piezo buzzer from 5volts. I figured it out. It is super simple and as loud as your fire alarm. If you have struggled with this problem... give yourself a break... there is zero good information on the internet. Many forum suggestions exist and I tried all these without success:

I spent more hours than I will admit. Go to the dollar store and purchase their Intruder Alert noise maker and your'll find... an Auto Transformer and a 'black blob' of circuitry. The black blob is a pulsing square wave that the Arduino can produce.

The tranformer works well. If anyone can explain the phyisics behind its operation, pleas chime in! thanks.

The auto-transformer has three leads and you can measure the resistance across the leads to determine which is which.  Here is the transformer that I measured: Pin1-2 154ohm and Pin 2-3 8ohm Pins 1-3 is ~161ohm.  Also ozitronics posted some data (see picture) on his 'autotransformer' with similar resistance and 91mH/2.1mH inductance. If anyone can find similar transformers on Mouser I'd be interested in seeing it. thanks!

Credits: I stole the pictures/knowledge/ and content from the following places:
- How to harvest a piezo.(just a picture)
- this fellow has a couple circuits using 555 timers to produce a square wave using an auto transformer. PDF version
- Jack Lopez provided this nice schematic of the dollar store with 'black blob' circuit


Step 1: How to Drive a Piezo With an Arduino

Look up the piezo buzzer's resonant frequency.  This one has a peak frequency of 2600 HZ shown on the cut sheet. It actually has two peak frequencies but I just chose one. The cut sheet selects the point in the middle of the two frequencies.

Next calculate the square wave you need to make on the Arduino. 1 second / 2600 = 385us (micro seconds).

The square wave is positive for half the time and neutral for half the time or 385/2 = 192us

You may use other frequencies but this is one of the loudest frequencies based on the mfg literature.

Arduino Code: 

int piezoPin = 5;

void setup() {               
pinMode(piezoPin, OUTPUT);

void loop() {

analogWrite(piezoPin, 255);  //positive square wave
delayMicroseconds(192);      //192uS

analogWrite(piezoPin, 0);     //neutral square wave
delayMicroseconds(192);      //192uS