You are on page 1of 2

Buzzer

What you will need - Hardware


For this tutorial you will need:

 Arduino uno
 Breadboard
 Buzzer/piezo speaker
 100 Ohm resistor

The coder
Here's the "Tone" code.
How it works? It's simple, tone(buzzer, 1000) sends a 1KHz sound
signal to pin 9, delay(1000) pause the program for one second and
noTone(buzzer) stops the signal sound. The loop() routine will make this
run again and again making a short beeping sound.
(you can also use tone(pin, frequency, duration) function)
1 /* Arduino tutorial - Buzzer / Piezo Speaker
2 More info and circuit: http://www.ardumotive.com/how-to-use-a-buzzer-
3 en.html
4 Dev: Michalis Vasilakis // Date: 9/6/2015 // www.ardumotive.com */
5
6 const int buzzer = 9; //buzzer to arduino pin 9
7
8 void setup(){
9 pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
10 }
11
12 void loop(){
13 tone(buzzer, 1000); // Send 1KHz sound signal...
14 delay(1000); // ...for 1 sec
15 noTone(buzzer); // Stop sound...
16 delay(1000); // ...for 1sec
}

You might also like