Arduino PIR Motion Sensor – Complete Guide

Arduino PIR Motion Sensor – Complete Guide

Arduino is Open-Source Hardware Prototype used by Enthusiasts, hobbyists, and Computer Science Student.

Arduino is capable of doing lots of things with the help of Sensors, we could make anything using Arduino and Sensors.

Arduino easily set up with sensors and communicate. In this example, we are going to experiment with PIR Motion Sensor.

PIR Motion Sensor is a Passive Infrared Motion Sensor, it senses data if something moves around it.

With the help of Arduino and PIR Motion Sensor, we could make many projects or do many experiments like Motion Detector, Security Alert, or else.

So in this example, we are going to experiment with PIR Motion Sensor.

int sensorPin = 8;
int sirenPin = 9;
int pir;

void setup() {
  
  pinMode(sensorPin, INPUT);
  pinMode(sirenPin, OUTPUT);
  
  Serial.begin(9600);         
}

void loop() {
 pir = digitalRead(sensorPin);            
 if(pir == 1)
 {
  
  Serial.println("Motion detected"); 
  digitalWrite(sirenPin, HIGH);     
  delay(2000);                            
 }
 else
 {
 
  Serial.println("no motion");
  digitalWrite(sirenPin, LOW);
  delay(2000);
 }

}
Fig: PIR Motion Sensor Project




Copyright © 2020-2021 Engineer Jagat All rights reserved. Developed by Ravindra Rana