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

Arduino UNO-Based Motion-Activated Alarm System with LED Indicator and Piezo Buzzer

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

Circuit Documentation

Summary

This circuit is designed to use a PIR sensor and a toggle switch to control an LED and a piezo buzzer using an Arduino UNO. When both the PIR sensor detects motion and the toggle switch is activated, the LED lights up and the buzzer sounds for a specified duration.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LED: Two Pin (red)

    • Description: A red LED with two pins.
    • Pins: cathode, anode
  3. Resistor

    • Description: A resistor with a resistance of 200 Ohms.
    • Pins: pin1, pin2
    • Properties:
      • Resistance: 200 Ohms
  4. PIR sensor

    • Description: A passive infrared sensor used to detect motion.
    • Pins: VDD, SIG, GND
  5. Toggle Switch

    • Description: A switch with three pins.
    • Pins: L1, COM, L2
  6. Piezo Buzzer

    • Description: A piezoelectric buzzer with two pins.
    • Pins: pin 1, pin 2

Wiring Details

Arduino UNO

LED: Two Pin (red)

Resistor

PIR sensor

Toggle Switch

Piezo Buzzer

Code Documentation

Arduino UNO Code

const int led = 4;
int pir = 3;
int holderpir = 0;
int slide = 5;
int holderslide = 0;
int buzzer = 12;

void setup() {
    pinMode(led, OUTPUT);
    pinMode(pir, INPUT);
    pinMode(slide, INPUT);
    pinMode(buzzer, OUTPUT);
}

void loop() {
    holderpir = digitalRead(pir);
    holderslide = digitalRead(slide);

    if (holderslide == 1 & holderpir == 1) {
        digitalWrite(led, HIGH);
        analogWrite(buzzer, 255);
        delay(10000);
    }
    digitalWrite(led, LOW);
    analogWrite(buzzer, 0);
}

This code initializes the pins for the LED, PIR sensor, toggle switch, and piezo buzzer. In the main loop, it reads the state of the PIR sensor and the toggle switch. If both are activated, it turns on the LED and the buzzer for 10 seconds. After that, it turns off the LED and the buzzer.