Specifications:
- Operating Voltage: DC 3-24V
- Type: Continuous sounder electronic buzzer
- Dimensions: Straight: 23 mm, Height: 11 mm, Pitch: 30 mm
Features:
- Small size with high-decibel alarm
How to Connect the Buzzer to Arduino:
- Connect the piezo wires to the breadboard.
- Insert a 100Ω resistor to limit the current to protect the Arduino output pin.
- Connect the red wire from the piezo to digital pin 8 on the Arduino.
- Connect the black wire from the piezo to one end of the resistor, and connect the other end of the resistor to the Arduino GND (ground) pin.
Arduino Code:
// Specify digital pin connected to positive lead of piezo buzzer
int piezoPin = 8;
void setup() {
// No setup needed
}
void loop() {
/* tone() needs 2 arguments, can take 3:
1) Pin
2) Frequency in hertz (pitch)
3) Duration (optional)
*/
tone(piezoPin, 1000); // Play 1000 Hz tone
// delay(1000); // Optional delay if you want a pause
}
This code generates a 1000 Hz tone on pin 8. You can change the frequency by modifying the value inside the tone()
function.
Specifications:
- Operating Voltage: DC 3-24V
- Type: Continuous sounder electronic buzzer
- Dimensions: Straight: 23 mm, Height: 11 mm, Pitch: 30 mm
Features:
- Small size with high-decibel alarm
How to Connect the Buzzer to Arduino:
- Connect the piezo wires to the breadboard.
- Insert a 100Ω resistor to limit the current to protect the Arduino output pin.
- Connect the red wire from the piezo to digital pin 8 on the Arduino.
- Connect the black wire from the piezo to one end of the resistor, and connect the other end of the resistor to the Arduino GND (ground) pin.
Arduino Code:
// Specify digital pin connected to positive lead of piezo buzzer
int piezoPin = 8;
void setup() {
// No setup needed
}
void loop() {
/* tone() needs 2 arguments, can take 3:
1) Pin
2) Frequency in hertz (pitch)
3) Duration (optional)
*/
tone(piezoPin, 1000); // Play 1000 Hz tone
// delay(1000); // Optional delay if you want a pause
}
This code generates a 1000 Hz tone on pin 8. You can change the frequency by modifying the value inside the tone()
function.