0% found this document useful (0 votes)
57 views8 pages

Lecture 10 Experiment-14

This document describes building an intrusion alarm system using an Arduino, PIR motion sensor, and buzzer. The system will detect motion using the PIR sensor and sound an alarm with the buzzer. The circuit connects the sensor and buzzer to Arduino pins and code makes the buzzer sound when motion is detected and stop when motion is no longer detected. The exercise asks to modify the system to also blink an LED and display "Motion Detected!" on an LCD when motion is sensed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views8 pages

Lecture 10 Experiment-14

This document describes building an intrusion alarm system using an Arduino, PIR motion sensor, and buzzer. The system will detect motion using the PIR sensor and sound an alarm with the buzzer. The circuit connects the sensor and buzzer to Arduino pins and code makes the buzzer sound when motion is detected and stop when motion is no longer detected. The exercise asks to modify the system to also blink an LED and display "Motion Detected!" on an LCD when motion is sensed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

ECE 2030

Arduino Based System Design

Daw Khaing Su Wai


Experiment 14

Building an Intrusion alarm system


(Motion sensor and speaker)
Building an Intrusion alarm system
Components
• Arduino UNO Board
• PIR Sensor
• Buzzer

https://arduinogetstarted.com/tutorials/arduino-motion-sensor-piezo-buzzer
Building an Intrusion alarm system
Circuit Diagram

https://arduinogetstarted.com/tutorials/arduino-motion-sensor-piezo-buzzer
Building an Intrusion alarm system

• If the motion is detected, make sound.


• If the motion is not detected, stop making sound.
Building an Intrusion alarm system
/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-motion-sensor-piezo-buzzer
*/

const int MOTION_SENSOR_PIN = 7; // Arduino pin connected to the OUTPUT pin of motion sensor
const int BUZZER_PIN = 3; // Arduino pin connected to Buzzer's pin
int motionStateCurrent = LOW; // current state of motion sensor's pin
int motionStatePrevious = LOW; // previous state of motion sensor's pin

void setup() {
Serial.begin(9600); // initialize serial
pinMode(MOTION_SENSOR_PIN, INPUT); // set arduino pin to input mode
pinMode(BUZZER_PIN, OUTPUT); // set arduino pin to output mode
}
Building an Intrusion alarm system
void loop() {
motionStatePrevious = motionStateCurrent; // store old state
motionStateCurrent = digitalRead(MOTION_SENSOR_PIN); // read new state

if (motionStatePrevious == LOW && motionStateCurrent == HIGH) { // pin state


change: LOW -> HIGH
Serial.println("Motion detected!");
digitalWrite(BUZZER_PIN, HIGH); // turn on
}
else
if (motionStatePrevious == HIGH && motionStateCurrent == LOW) { // pin state
change: HIGH -> LOW
Serial.println("Motion stopped!");
digitalWrite(BUZZER_PIN, LOW); // turn off
}
Building an Intrusion alarm system

Exercise

• If the motion is detected, make sound, blink LED and print


“Motion Detected!” on LCD.

You might also like