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

Arduino UNO-Based Alarm System with PIR Sensor and RTC Module

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Alarm System with PIR Sensor and RTC Module

Circuit Documentation

Summary

This circuit is designed to interface with an Arduino UNO microcontroller, a Real-Time Clock (RTC) module, a Passive Infrared (PIR) sensor, a piezo buzzer, and multiple LEDs. The system is programmed to set alarms at 9:00 AM, 12:00 PM, and 9:00 PM. When an alarm triggers, the LEDs blink in a specific order. If the PIR sensor detects motion, the buzzer and LEDs will turn off. The circuit is powered by an 18650 Li-ion battery.

Component List

Wiring Details

Arduino UNO

PIR/Motion Sensor

LEDs (Red)

18650 Li-ion Battery

Piezo Buzzer

16x2 I2C LCD

Resistor (330 Ohms)

RTC Module

Documented Code

/*
 * This Arduino sketch interfaces with an RTC module, a PIR sensor, a piezo buzzer,
 * and multiple LEDs. The system sets alarms at 9:00 AM, 12:00 PM, and 9:00 PM.
 * When an alarm triggers, LEDs blink in a specific order. If the PIR sensor
 * detects motion, the buzzer and LEDs will turn off.
 */

#include <Wire.h>
#include <RTClib.h>

RTC_DS3231 rtc;

const int buzzerPin = 10;
const int pirPin = A0;
const int ledPins[] = {2, 3, 4, 5, 6, 7};

void setup() {
  Serial.begin(9600);
  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  pinMode(buzzerPin, OUTPUT);
  pinMode(pirPin, INPUT);
  for (int i = 0; i < 6; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  DateTime now = rtc.now();
  int pirState = digitalRead(pirPin);

  if (pirState == HIGH) {
    digitalWrite(buzzerPin, LOW);
    for (int i = 0; i < 6; i++) {
      digitalWrite(ledPins[i], LOW);
    }
  } else {
    if ((now.hour() == 9 && now.minute() == 0) ||
        (now.hour() == 12 && now.minute() == 0) ||
        (now.hour() == 21 && now.minute() == 0)) {
      triggerAlarm();
    }
  }
  delay(1000);
}

void triggerAlarm() {
  for (int i = 0; i < 6; i++) {
    digitalWrite(ledPins[i], HIGH);
    delay(500);
    digitalWrite(ledPins[i], LOW);
  }
  tone(buzzerPin, 1000, 1000);
}

This code is responsible for setting up the Arduino UNO to interact with the connected components. It initializes the RTC module, sets up the PIR sensor, buzzer, and LEDs, and contains the main loop that checks for motion and triggers the alarm at the specified times.