How to Use a Piezo to Produce Tone : Basics

5,902

67

4

About: So, I got a bunch of LEDs when I was 8 or 9 something.

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

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

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

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

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.

Maker Olympics Contest 2016

Participated in the
Maker Olympics Contest 2016

Makerspace Contest

Participated in the
Makerspace Contest

Share

    Recommendations

    • Sew Tough Challenge

      Sew Tough Challenge
    • Planter Challenge

      Planter Challenge
    • Games Contest

      Games Contest

    4 Discussions

    0
    None
    donhaynes

    2 years ago

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

    1 reply
    0
    None
    Anshu ARdonhaynes

    Reply 2 years ago

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

    0
    None
    chetancc

    2 years ago

    Please put video for demonstration if possible :)

    1 reply
    0
    None
    Anshu ARchetancc

    Reply 2 years ago

    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.