Buzzer with Arduino - Chase - Learn

Recent Posts

test

Monday, 2 April 2018

Buzzer with Arduino


Overview
A buzzer or beeper is an audio signalling device, which may be mechanical, electromechanical, or piezoelectric. Typical use of buzzers and beepers include alarm devices, timers, and confirmation of user input such as a mouse click or keystroke.
Image result for buzzer


Interfacing the Buzzer

Connecting Buzzer to a microcontroller is really simple. The Buzzer uses only two pins GND, and a pin to any of the Arduino digital pin.

Image result for buzzer with arduino


Code
/*
* Buzzer and Arduino
*
*
*/
const int buzzer = 8; //buzzer to arduino pin 9

void setup(){
  pinMode(buzzer, OUTPUT); // Set buzzer - pin 8 as an output
}

void loop(){
  tone(buzzer, 1000); // Send 1KHz sound signal...
  delay(1000);        // ...for 1 sec
  noTone(buzzer);     // Stop sound...
  delay(1000);        // ...for 1sec
}

No comments:

Post a Comment