Loading... Please wait...

Piezo Transducer (Passive Buzzer)

Piezo Transducer (Passive Buzzer)

This example shows how to play a tone on a passive piezo buzzer.

  • Arduino Board
  • Passive Piezo Transducer / Buzzer


To build the circuit, connect one side of the piezo transducer to pin 9 and the other side to GND.



image developed using Fritzing. For more circuit examples, see the Fritzing project page



 This example shows how to run a Piezo Buzzer on pin 9
 using the analogWrite() function.
 It beeps 3 times fast at startup, waits a second then beeps continuously
 at a slower pace

void setup()  { 
  // declare pin 9 to be an output:
  pinMode(9, OUTPUT);

void loop()  { 

void beep(unsigned char delayms){
  analogWrite(9, 20);      // Almost any value can be used except 0 and 255
                           // experiment to get the best tone
  delay(delayms);          // wait for a delayms ms
  analogWrite(9, 0);       // 0 turns it off
  delay(delayms);          // wait for a delayms ms   

What's News


Copyright 2020 oddWires. All Rights Reserved.
 Sitemap | oddWires