Hassan Shettima Lawan
Published © GPL3+

Motion Detection Alarm System

The system uses a PIR sensor to detect motion and send to the Arduino, which in turn triggers a buzzer and LED simultaneously.

BeginnerFull instructions provided2 hours29,684
Motion Detection Alarm System

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
buzzer module
×1
Jumper wires (generic)
Jumper wires (generic)
×8

Software apps and online services

Arduino IDE
Arduino IDE
Microsoft Visio 2016

Story

Read more

Custom parts and enclosures

Motion Detection

Block diagram of hardware and how they are connected to one another.

Code

Motion Detection

C/C++
Copy and paste in your IDE.
//HASSAN SHETTIMA LAWAN
//hassanshettima705@gmail.com
int buzzerPin = 8;                          //BUZZER INPUT PIN.
int ledPin = 13;                            //LED PIN.
int pirPin = A0;                            //MOTION SENSOR INPUT PIN.
int sensorValue = LOW;                      //DEFAULT SENSOR STATE.

void setup() {                              //INITIAL SETTINGS/ASSIGNMETN.
  pinMode(buzzerPin, OUTPUT);               //SET BUZZER AS OUTPUT.
  pinMode(ledPin, OUTPUT);                  //SET LED AS OUTPUT.
  pinMode(pirPin, INPUT);                   //SET PIR AS INPUT.
}
void loop() {                               //COMMAND TO BE REPEATED.
  sensorValue = digitalRead(pirPin);        //READ PIR INPUT PIN.
  if ( sensorValue == HIGH) {               //IF MOTION IS DETECTED.
    tone(buzzerPin, 1200);                  //BUZZ THE BUZZER. 
    digitalWrite(ledPin, HIGH);             //ON LED.
    delay(100);                             //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).
    noTone(buzzerPin);                      //SILENT BUZZER.
    digitalWrite(ledPin, LOW);              //OFF LED.
    delay(100);                             //TIME DIFFERENCE BETWEEN HIGH(ON)& LOW(OFF).
  }
  else {                                    //IF NO MOTION IS DETECTED.
    noTone(buzzerPin);                      //SILENT THE BUZZER.
    digitalWrite(ledPin, LOW);              //OFF LED.
  }
}

Credits

Hassan Shettima Lawan

Hassan Shettima Lawan

2 projects • 15 followers
Electrical electronics engineering technologist. Learning is a hobby.

Comments