Introduction: How to Use a Piezo to Produce Tone : Basics

Picture of How to Use a Piezo to Produce Tone : Basics

Hello everyone, In this instructable, We will be using a Piezo buzzer to produce tone.

What is a Piezo buzzer?

  • A Piezo is a electronic device that can be used both to produce as well as detect sound.

Applications:

  • You can use the same circuit to play a musical note by switching the Piezo on and off several times.
  • The experience can be further improved by changing the loudness of the Buzzer using Arduino PWM pins.

We will be starting from basics and will produce a simple Beeping tone using Piezo.

Step 1: Gather the Parts

Picture of Gather the Parts

For this project we will need:

  1. An Arduino UNO
  2. A 5V Piezo Buzzer
  3. Jumper wires

Don't we need a resistor to limit the current through the buzzer?

No, if you are using a small 5V Piezo.

As it derives or uses very small amount of current so can be used without a resistor in series.

Step 2: Wiring

Picture of Wiring

Hookup all the components according to the circuit shown above.

Polarity of the buzzer:

Before connecting the Piezo to Arduino, note that a Piezo buzzer has polarity.

  1. The positive lead of the Piezo has Red wire.
  2. But, If you have got a Breadboard mountable Piezo then the Positive terminal of the Piezo has a longer lead than negative terminal.

Step 3: Arduino Sketch

Picture of Arduino Sketch

Once you have wired up everything, Upload the following to Arduino:

void setup()  { 
  pinMode(9, OUTPUT);        // declare pin 9 to be an output:
}
void loop(){
analogWrite(9, 20);       // Any value can be used except 0 and 255
delay(300);                   // wait for 3 ms
analogWrite(9, 0);         // turns it off
delay(300);                   // wait for 3 ms
}

Step 4: Done

Picture of Done

Once done power the Arduino to hear the beep.

Troubleshooting:

No sound

  • Check that the buzzer is connected to the arduino properly.

Have you inserted the buzzer to the correct pin?

  • Pay attention on the Polarity of the Piezo buzzer. That is, Positive lead of the buzzer should go to PIN 9 and negative to GND on the Arduino respectively.

If you still can't hear Re-upload the sketch.

Or, Write in comments below.

Thanks for viewing.

Comments

donhaynes (author)2016-10-10

Worked the first time! I'm always excited when that happens. What a horrid sound, though. It would make an excellent alarm clock.

Anshu AR (author)donhaynes2016-10-10

Congrats!
I know how it feels when you build something and that works without any problems.

chetancc (author)2016-09-02

Please put video for demonstration if possible :)

Anshu AR (author)chetancc2016-09-02

The video that I have linked contains the demonstration at the end.
As I have uploaded video to YouTube for the first time, The loudness of the video is very low.

About This Instructable

4,632views

66favorites

License:

Bio: So, I got a bunch of LEDs when I was 8 or 9 something.
More by Anshu AR:Scratch Built RC AirplaneH Bridge Motor Driver For Arduino Using TransistorsHow To Use A Piezo To Produce Tone : Basics
Add instructable to: