Free tools Windows power users keep installed
One-click scans. No signup required.
You can build an Arduino buzzer alarm in stages: first test the buzzer with tone() and noTone(), then add a sensor if you want the alarm to respond to motion or distance. Use a PIR sensor for movement in an area, or an HC-SR04 ultrasonic sensor to sound when an object is within a chosen range.
What you need
For the buzzer-only test, use an Arduino Uno Rev3, a buzzer or piezo speaker, jumper wires and a breadboard. A 100-ohm resistor is optional in the cited starter example. An Arduino UNO R3 starter kit can provide the board and basic prototyping parts; select a buzzer that matches the circuit and confirm its type before wiring it.
To make the alarm react to something, add either a PIR motion sensor module or an HC-SR04 ultrasonic sensor. The buzzer-only circuit is the best first test because it confirms that the board, wiring and output code work before you troubleshoot sensor readings.
Test the buzzer by itself
Connect the buzzer’s positive lead to digital pin 9 and its negative lead to GND. If your buzzer is polarized, follow its markings; do not assume every buzzer or piezo speaker has identical terminals. The Arduino Project Hub starter example uses pin 9 and produces a 1 kHz tone for one second, then silence for one second.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall#1 Best Overall
- High-volume boosts alerts with a robust 3-decibel output alert; ideal for Arduino, DIY electronics, and safety alarms
- Alarm pinger 9*5.5mm mini piezo buzzers easy 5V plug & play operation; Works seamlessly with computers and development boards
- Compact & energy efficient design draws <250mA current for versatile project integration
- Superior Sensitivity ensures clear audible signals from electronic toys to equipment
- Mini active piezo buzzer module with 9*5.5mm size, fits snugly in tight spaces without compromising sound quality
const int buzzer = 9;
void setup() {
pinMode(buzzer, OUTPUT);
}
void loop() {
tone(buzzer, 1000); // Start a 1 kHz tone
delay(1000);
noTone(buzzer); // Stop the tone
delay(1000);
}
Upload the sketch and listen for alternating one-second tone and silence. tone(pin, frequency) starts a frequency-driven signal; noTone(pin) stops it. If there is no sound, check the selected pin, GND connection, buzzer polarity and whether the part is an active buzzer or a passive piezo device. The example demonstrates a signal, not a guaranteed sound level.
Choose a sensor for the alarm behavior
| Option | What triggers the buzzer | Connections and example behavior | What to consider |
|---|---|---|---|
| PIR motion sensor | Movement detected within the sensor’s field of view. | The cited Arduino Project Hub burglar-alarm project pairs an Uno, PIR sensor and buzzer, and also includes a 16×2 LCD and an entry timer. Its PIR sensor is specified with a 7 m range. | Mounting and field of view determine what movement is visible. A PIR reacts to motion, not simply to an object being present. The cited project does not establish controlled accuracy or false-alarm rates. |
| HC-SR04 ultrasonic sensor | Measured distance at or below a threshold. | The cited project uses trigger pin 9, echo pin 10 and buzzer pin 8; it sounds when its calculated distance is 50 cm or less. | It requires two sensor signal pins and distance-measurement code. Position the sensor so the object of interest is in front of it; the cited example does not establish controlled accuracy or false-alarm rates. |
Pick PIR when movement in an area is the event you care about. Pick HC-SR04 when the event is an object getting closer than a selected distance. These are different behaviors, not interchangeable ways to detect the same condition.
Rank #2
- Passive Piezo Buzzer Module (2-Pack) – Generates sound based on input signal frequency, allowing for customizable audio tones and sound effects in DIY projects.
- Adjustable Frequency Output – Control pitch and tone using PWM signals from your microcontroller—ideal for creating music or alerts.
- Low Power & Broad Voltage Support – Operates with minimal power and works with 3.3V to 5V systems, including Arduino, ESP32, and Raspberry Pi.
- Compact & Easy to Use – Small, lightweight design with simple wiring makes it perfect for embedded systems, smart devices, or educational kits.
- Tutorials Available Online – Search “DIYables passive buzzer module” for example projects using Arduino, ESP32, ESP8266, and Raspberry Pi.
Build an HC-SR04 distance alarm
Wire the sensor and buzzer
Use an Arduino Uno Rev3, HC-SR04 ultrasonic sensor, 5 V active buzzer, breadboard and jumper wires. Connect the sensor’s VCC to 5V and GND to Arduino GND. Connect TRIG to digital pin 9 and ECHO to digital pin 10. Connect the buzzer’s positive lead to pin 8 and its negative lead to GND. The Arduino, sensor and buzzer need a common ground for their signals to share the same reference.
| Part | Arduino connection |
|---|---|
| HC-SR04 VCC | 5V |
| HC-SR04 GND | GND |
| HC-SR04 TRIG | Digital pin 9 |
| HC-SR04 ECHO | Digital pin 10 |
| 5 V active buzzer positive | Digital pin 8 |
| 5 V active buzzer negative | GND |
Upload the distance-alarm sketch
This sketch sends a short trigger pulse, measures the echo duration with pulseIn(), converts that time to an approximate distance using the cited example’s formula, and sounds the buzzer at 50 cm or closer.
Rank #3
- Passive Buzzer Module: Generates sound based on input signals, perfect for custom audio alerts in various projects.
- Frequency Adjustable: Control the tone and pitch by adjusting the input frequency, ideal for creating different sound effects.
- Low Power Consumption: Operates efficiently with minimal power, compatible with 3.3V to 5V systems.
- Wide Compatibility: Tutorials for Arduino, ESP32, ESP8266, Raspberry Pi are provided => Search for: DIYables passive buzzer module.
- Compact and Easy to Use: Small form factor, ideal for integrating into compact designs and quick prototyping.
const int buzzer = 8;
const int trigPin = 9;
const int echoPin = 10;
void setup() {
pinMode(buzzer, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long timing = pulseIn(echoPin, HIGH);
float distance = (timing * 0.034) / 2;
if (distance > 0 && distance <= 50) {
tone(buzzer, 500);
} else {
noTone(buzzer);
}
}
The added check for a positive measured distance avoids treating a zero return from pulseIn() as an object inside the threshold. The cited project’s core threshold is 50 cm; change that comparison to tune the trigger distance. Its example uses a 500 Hz tone.
Use a PIR sensor for motion detection
A PIR alarm turns on when the sensor reports movement, so its logic differs from the HC-SR04’s distance comparison. The cited Arduino Project Hub build uses an Uno, PIR sensor and buzzer, with a 16×2 LCD and timer to record when entry was detected. It specifies a PIR sensor with a 7 m range, but does not provide controlled detection or false-alarm measurements.
Rank #4
- Product Name: Electronic Alarm Buzzer; Dimension: 0.47X0.37"/12x8.5mm(Dx H).
- Application:Suitable for electronic toys, safety equipment, development boards,etc
- Plastic housing, 3-5V input, 2 terminals, 2000HZ resonance frequency
- Feature: All multi-chip integrated circuits using gold wire ball bonding, complex production process, long life, stable performance, high rate of qualified products.
- 20PCS DC 3V Active Buzzer 2 Terminals for Arduino Raspberry Pi,Magnetic Electronic Continous Long Beep Tone Alarm Sounder
Connect the PIR module’s power and ground according to its labeling, and connect its digital output to an Arduino input pin. Keep the grounds common, and connect the buzzer as in the buzzer-only test. In code, read the PIR output and call tone() when the output indicates motion; call noTone() when it does not. PIR modules can differ in pin labels and adjustment controls, so use the wiring information for the specific module rather than assuming one universal pin order.
Improve the prototype before relying on it
- Add an alarm state: Use a variable to latch the alarm after a trigger, then require a reset or disarm action rather than stopping immediately when a PIR output changes or an object moves away.
- Add a cooldown: Decide how long the buzzer should sound and how soon the system may trigger again. This makes the behavior predictable, but the suitable timing depends on the intended use.
- Add a disarm control: A button or switch can prevent the buzzer from sounding while you are testing or entering the monitored area. Define and test its behavior before leaving the system unattended.
- Test placement and conditions: Check the PIR’s coverage where it is mounted, or test the HC-SR04 with objects at the distances that matter. The cited examples do not provide independent accuracy, loudness or false-alarm benchmarks.
These hobby circuits are learning prototypes, not certified security systems. Do not rely on them as the sole protection for people or property. Arduino’s tutorial catalog lists Getting Started with Modulino Buzzer, Getting Started with Modulino Distance and UNO R3 among its supported products, showing that buzzer and distance projects remain represented in the Arduino ecosystem.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Quick Recap
Best Value
- Passive Buzzer with 2000Hz Core Tone: This is a passive electronic alarm buzzer with a 2000Hz resonance frequency. Unlike active buzzers that produce a single fixed tone, this component requires an external PWM/square wave signal from your microcontroller. By varying the input frequency, you can shift the tone pitch or generate simple melodies — perfect for electronic toys, DIY alarms, and safety equipment where distinct audio feedback is essential.
- Compact 2-Pin Design: Designed for space-constrained projects, this buzzer measures only 0.47 x 0.37 inches (12 x 8.5mm) . It features a simple 2-terminal pin configuration. Operating on a wide 3-5V DC input, it is lightweight and housed in durable black plastic.
- Long Lifespan & Stable Performance: Built with premium manufacturing standards, this buzzer utilizes multi-chip integrated circuits with gold wire ball bonding technology. This complex production process ensures superior connection reliability, extended operational life, and stable sound output.
- NOTE: Do NOT connect directly to DC 3V/5V. This buzzer WILL NOT MAKE SOUND if connected only to positive and negative power. It REQUIRES an external oscillating signal (PWM/Square Wave) typically generated by an Arduino tone() function via a transistor driver circuit.
- Versatile Applications: This 2-terminal passive buzzer is a universal fit for a wide range of applications: Electronic Toys: Talking dolls, RC car reverse beeps, game buzzers; Development Boards: Sound experiments with Arduino, Raspberry Pi Pico, ESP32 (requires external transistor driver); Safety Equipment: Low-power alarms for smoke detectors, door open alerts, and portable medical device reminders; General PCB Mounting: Standard spacing fits most prototyping PCBs and perfboards.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

