Celebrating Diwali from home away from home

Girls look stunningly beautiful in sarees. The gentlemen in bright coloured Kurtas — which were ordered recently for Diwali — are busy floating the sky-lanterns into the air. The traditional Indian…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Buzzer with Arduino

Buzzer with Arduino

A buzzer or piezo speaker is an audio signaling device commonly used to produce sound. Piezo buzzer produces sound based on the reverse principle of the piezoelectric effect. The buzzer is a less costly and light-weighted electronic device that’s why it is used in computers, alarm devices, refrigerators, microwave ovens, security devices, and so on.

There are two conductors available inside the buzzer along with a piezo crystal between them. Whenever the potential is applied across the crystal than the conductor’s position gets changed due to which 2 to 4 kHz sound wave produced by the buzzer.

connection diagram

A buzzer is a two-terminal (one is longer and another one is shorter) device. The longer leg is used to provide the input and the shorter leg is used to provide the ground connection. According to the circuit diagram, I have connected pin 7 of Arduino with the longer leg of the buzzer. The shorter leg of the buzzer is connected with the GND terminal of the Arduino Uno.

Here I am sharing three codes along with their output video which will help you to understand the working of the code in an efficient manner.

In this first example, I used “digitalwrite(pin, value)” command to operate the buzzer. In this syntax, the pin indicates the pin number and the value indicates the LOW or HIGH. To turn on the buzzer HIGH value is used and on the other side to turn off the buzzer LOW value is preferred in the command.

In this example, I used tone() function to operate the buzzer. There are two types of syntax used for tone() function.

I used different values to generate different tones. tone() function used to generate a square wave of the specified frequency. The duration of the tone can be specified with the frequency of the tone. If the duration is mentioned along with the tone() function then the tone will be generated only for the specified duration. If the duration is not mentioned in the tone() function then the noTone() function is needed to stop the tone.

Here I am attaching the output video for all codes which will help you to understand the working of the codes.

The tone function can also be used to generate piano notes of any song with the help of additional pitches.h file. Hence buzzer is a small, efficient, less costly, less bulky device that has the capability to generate different kinds of tones with very fewer efforts.

Add a comment

Related posts:

How to Understand Everything Political

Politicians of every sort want to create dependency upon the systems they represent, whether through force, advocacy or manipulation, and the primary tool of dependency is victimhood. Politicians…

The Tree that Brings Love Through War and Peace

War affects life long after it’s over. Bui Cong Khanh’s epic artwork comments on the long shadows of war reflecting beyond Vietnam’s history.

How long do you have insurance when you get layed off?

My husband was told to tonight that he and a few other employees were being cut for cost and will be getting layed off. It upset me because I’m pregnant and we’ll lose our health insurance. I myself…