How to Drive a Piezo With an Arduino




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


Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    15 Discussions


    2 years ago

    Great information here with all parts listed. After hours of searching. I find no one references the mysterious autotransformer part number. Why is this?

    Lorin EdwinP

    2 years ago

    Can also use an inductor in parallel with piezo with ground & a transistor to drive it. You can find coils that will work in old phones, power supplies, AV baluns, etc. You just need inductance to optimize current across capacitor over time.

    Lorin EdwinP

    2 years ago

    The reason you need the transformer is a matter of impedance. A
    piezoelectric element is rather high impedance, and very capacitive. In
    fact one generally treats them as a capacitor. So, a capacitor passes
    AC, but rejects DC. This fact, means that only the transitions in your
    square wave actually carry any power, so you're losing much of the power
    due to DC blocking. Further, piezos tend to dampen themselves
    mechanically due to a sharp resonance / antiresonance.

    So, here,
    the trick is that you're decoupling the capacitor (piezo) up off of
    ground and letting it couple at resonance with the inductive transformer
    winding. Think of a the way that a spring allows something to move more
    freely, even if it is tied to something quite heavy.

    If you use
    an audio transformer say 8ohm to 10kohm or more, you can actually get
    some pretty impressive frequency ranges, play music through it, even
    vibrate an object (thin wood, metal plate)...


    3 years ago

    You did a great job of giving lots of links to relevant and helpful places. Thanks! A great instructable


    3 years ago

    I think what you did is called a "balun" - it gets ground-biased 0-5 volts on input (when pins are switching between equal voltage and 5 volts difference) and produces differential 5 volts peak to peak AC voltage on output (when pins always differ by 5 volts, but are constantly swapping polarity). But your device is also a transformer, so the output voltage is higher (or lower), depending on the turns ratio.

    I'm trying to drive a buzzer myself right now with a similar generator (0-5 volts), but don't have any auto transformer at hand, so I would try to use a capacitor to remove DC offset and hope it works.


    4 years ago on Introduction

    Good work. I was looking for a solution to amplify sound of buzzer that I extracted from burglar alarm and found a way thanks to you !


    5 years ago on Introduction

    Hello Thomas!

    interesting project! I am still trying to understand how the autotransformer works.

    Is that similar to transistor? can I replace it using transistor ?


    - Dipta

    4 replies

    Reply 5 years ago on Introduction

    I think it is simply a super small inexpensive transformer. So it amplifies the piezo based on the turns on the coils. The dollar store 3-pin transformer that worked best had one small coil (8ohms worth of windings) and a larger coil with 154ohms of windings. The oscilating signal is fed into the small windings and the larger windings are attached across the Piezo.


    Reply 5 years ago on Introduction

    Oh ok thanks! I would like to make a similar circuit but smaller.

    Do you have any ideas to replace that autotransformer with anything?

    Op-Amp or NPN transistor maybe?


    5 years ago on Introduction

    I know I am cheating a little, but I just can't figure out how to build an autotransformer and I need something simple for my wearable project.

    So I bought buzzers instead:

    You just need to feed it a high output directly from the arduino and it gives a loud beep until you turn it off. And I got two kinds to test:

    This one is smaller/cheaper (loud beep, but not scary loud)

    And this one: (More expensive, even louder than the one above, but bigger)


    5 years ago on Introduction

    Hey, Thomas

    I found the physics behind this autotransformer if you'd like

    1 reply

    Reply 5 years ago on Introduction

    Cool. I only skimmed it but I'll update the instructable when I get a minute. Thanks for taking the time to send it to me. - Thomas