Buzzer With Arduino Uno Tutorial

by Rachna Aggarwal in Circuits > Arduino

1296 Views, 0 Favorites, 0 Comments

Buzzer With Arduino Uno Tutorial

fR of alarm.jpg

In this project a tone is generated by buzzer when set to high in Arduino code.

Buzzer - Piezo buzzers are simple devices that can generate basic beeps and tones. They work by using a piezo crystal, a special material that changes shape when voltage is applied to it. If the crystal pushes against a diaphragm, like a tiny speaker cone, it can generate a pressure wave which the human ear picks up as sound.

Ways of getting output from Arduino for buzzer:-

1. When connected to digital input/output pin buzzer get two values HIGH and LOW .

2. When connected to PWM pins namely pin 3,5,6,9,10,11 we can send values between 0V to 5V .

Components Required

Circuit Schematic

alarm.PNG
buzzer terminal.jpg

Pin 8 --> buzzer positive

GND --> buzzer negative

Arduino Code

Upload buzzer.ino code to run this project.

void setup() {
// put your setup code here, to run once:

pinMode(8, OUTPUT);

}

void loop() {

// put your main code here, to run repeatedly:

digitalWrite(8,HIGH);

delay(1000);

digitalWrite(8,LOW);

delay(5000); }

Upload tone_function.ino code but remember to attach buzzer with PIN 6 as it is a PWM pin.

tone(pin number, frequency);

frequency is generated from 31 to 65540 but we prefer values between 1000 to 5000 which are tolerable for human ears.