Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Motion-Activated Alarm with Piezo Buzzer

View and Edit Project In Cirkit DesignerImage of Arduino UNO Motion-Activated Alarm with Piezo Buzzer

Circuit Documentation

Summary

This circuit consists of an Arduino UNO microcontroller, a Piezo Buzzer, and a PIR sensor. The PIR sensor detects motion and triggers the Piezo Buzzer to sound an alarm when motion is detected.

Component List

Arduino UNO

Piezo Buzzer

PIR Sensor

Wiring Details

Arduino UNO

Piezo Buzzer

PIR Sensor

Code Documentation

Arduino UNO Code

void setup() {
  // Initialize the Piezo Buzzer pin as an output
  pinMode(7, OUTPUT); // Piezo Buzzer connected to pin D7
  
  // Initialize the PIR sensor pin as an input
  pinMode(9, INPUT);  // PIR Sensor connected to pin D9
}

void loop() {
  // Read the state of the PIR sensor
  int pirState = digitalRead(9); // Read PIR sensor state from pin D9
  
  // Check if the PIR sensor is triggered
  if (pirState == HIGH) {
    // If the PIR sensor is triggered, turn on the Piezo Buzzer
    digitalWrite(7, HIGH); // Set pin D7 HIGH to turn on the Piezo Buzzer
  } else {
    // If the PIR sensor is not triggered, turn off the Piezo Buzzer
    digitalWrite(7, LOW); // Set pin D7 LOW to turn off the Piezo Buzzer
  }
}

This code initializes the Piezo Buzzer pin as an output and the PIR sensor pin as an input. In the main loop, it continuously reads the state of the PIR sensor. If motion is detected (PIR sensor state is HIGH), the Piezo Buzzer is turned on. If no motion is detected (PIR sensor state is LOW), the Piezo Buzzer is turned off.