Wednesday, 11 April 2018

Arduino with Buzzer

Buzzer:

A buzzer or beeper is an audio signalling device,which may be mechanical, electromechanical, or piezoelectric (piezo for short range). Buzzers are used as alarm devices, timers, and confirmation of user input such as a mouse click or keystroke.
medium-piezo-transducer-buzzer-800x609
Buzzer
Mostly Piezoelectric Buzzers are used for projects. It has the ability to generate electricity when mechanical pressure is applied to piezo electric materials and the vice versa is also possible. When subjected to an alternating electric field they stretch or compress, with the frequency of the signal and produce sound.

Hardware Required:

  • Breadboard
  • Buzzer
  • 100 ohm resistor
  • Arduino

Software Required:

  • Arduino UNO

Steps to connect :

Step 1: Connect the buzzer in the breadboard
Step 2: Connect 100 ohm resistor across the buzzer, resistor is used to avoid damage to the buzzer
Step 3: Now connect the positive side of buzzer (RED wire) to the digital pin 9 through resistor
Step 4: Connect the negative terminal of buzzer (Black wire) to the ground.
arduino-with-buzzer
Arduino with Buzzer

Code:
const int buzzerPin = 9;
void setup()
{
Serial.begin(8600);
pinMode(buzzerPin, OUTPUT);
void loop()
{
tone(buzzerPin,1000);
delay(1000);
noTone(buzzerPin);
delay(1000);
}

Coding Explanation:
const int buzzerPin = 9:
It indicates that buzzer is connected to 9th pin of arduino

pinMode(buzzerPin, OUTPUT):
It informs arduino such that buzzer is made as an output

tone(buzzerPin,1000):
It orders the arduino to tone buzzer pin with 1KHz signal

noTone(buzzerPin):
It orders the arduino not to tone buzzer pin

delay(1000) :
This provides a delay of 1 sec between on and off of buzzer

No comments:

Post a Comment

Arduino with Buzzer

Buzzer: A buzzer or beeper is an audio signalling device,which may be mechanical, electromechanical, or piezoelectric (piezo for short ra...