To Use a Buzzer with Arduino, We have used the link: http://www.instructables.com/id/How-to-use-a-Buzzer-Arduino-Tutorial/?ALLSTEPS
Step 1: We need to make the connection as per the below circuit:
Step 2: Connect the jumper cables to the Piezo Buzzer. Connect he positive cable to the longer wire on the Buzzer.
In case of sensors, positive terminal is the longer wire.
Step 3: Connect the Positve jumper cable to Pin 9 and the negative jumper cable to ground:
Always remember, when connecting cables, positive will connect to positive and negative to negative / ground.
Step 4: Connect the Arduino UNO R3 to the computer using the USB printer cable :
Step 5: Upload the following code to Arduino: This is for providing power supply to the Arduino UNO R3 board.
/* Arduino tutorial - Buzzer / Piezo Speaker
More info and circuit: http://www.ardumotive.com/how-to-use-a-buzzer-en.html
Dev: Michalis Vasilakis // Date: 9/6/2015 // www.ardumotive.com */
const int buzzer = 9; //buzzer to arduino pin 9
void setup(){
pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
}
void loop(){
tone(buzzer, 50); // Send 1KHz sound signal...
delay(1000);
noTone(buzzer); // Stop sound...
delay(1000); // ...for 1sec
}
This code has sounded the buzzer for 1 second and stopped sounding the buzzer for next 1 second. This cycle in continued in a infinite loop.
No comments:
Post a Comment