Introduction: Make Doorbell Using Piezoelectric Buzzer

About: " Work until you no longer have to introduce yourself " Show some love on Instagram @makers_bee & Motivate me on YouTube @MakersBee

Welcome Back Makers!

In this Instructable, we will see how to use piezoelectric buzzer and a push button.

When the push button is pressed, the buzzer will give alarm indicating to open the door.

So, let's get started!!

Step 1: Components Needed

All That You Need

Hardware Required

  • NodeMCU
  • Push Button
  • 10K ohm resistor
  • Bread Board
  • Micro USB cable
  • Connecting Wires

Software Required

  • Arduino IDE (with ESP8266 Library installed)

Note: You can connect the Buzzer directly to the Microcontroller if you wanted to, or you can connect a 100 ohm resistor in series with the buzzer.

Step 2: Description

Piezo buzzer is an electronic device commonly used to produce sound.

What is Piezo?

Piezo is the phenomena of generating electricity when mechanical vibration is applied to certain materials. Such materials are called piezoelectric materials.

Therefore, when buzzer is subjected to an electric field they vibrate with certain frequency thereby producing sound. Frequency of vibration depends upon the material used inside the material.

Step 3: Wiring Conections

The Connections are pretty simple.

Push Button connections :
The first pin goes from one leg of the pushbutton through a pull-up resistor (here 10K Ohms) to the 5v supply.

The second pin goes from the corresponding leg of the pushbutton to Ground (GND) pin.

The third pin connects to a Digital I/O pin (here pin D0) which reads the button's state.

Buzzer connections :

Buzzer Anode (RED) is connected to Digital I/O pin (here pin D1) and Cathode (BLACK) to ground (GND) pin.

Get ready to Code.

Step 4: Code Is Here

const int buzzer = 5;

const int button = 16;

int temp = 0;
void setup() {

  Serial.begin(9600);
  pinMode(buzzer, OUTPUT);
  pinMode(button, INPUT);

}
void ring() {                  // You can tinker with this loop to make your own tone.

  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
  delay(500);
  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
  delay(500);
  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
  delay(500);
  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
  delay(500);
  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
  delay(500);
  digitalWrite(buzzer, HIGH);

}
oid loop() {

  temp = digitalRead(button);
     
     if (temp == HIGH) {
        ring();                                     // function call RING to make the tone.
        Serial.println(" Please Open the Door ");
        delay(1000);
       }
     else {
        digitalWrite(buzzer, LOW);
        Serial.println(" Ring the Bell ");
        delay(1000);
       }
}

Download the "Buzzer_NodeMCU.ino" file and open it up in the Arduino IDE.

Then Create a new sketch and paste the code below in the Arduino IDE and hit Upload. You can tinker with it if you like based on the application, or just use it as it is.

Step 5: Output

That's all Makers.

You have successfully completed another instructable, It takes pretty less time to create this instructable, and its fun too.

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017