rudraksh2008
Published

Interfacing PIR sensor with Arduino

Make use of this project and catch the thief entering your home with the PIR sensor!

IntermediateFull instructions provided362
Interfacing PIR sensor with Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Resistor 220 ohm
Resistor 220 ohm
×1
5 mm LED: Red
5 mm LED: Red
×1
Buzzer
Buzzer
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
PIR Sensor, 7 m
PIR Sensor, 7 m
×1
Male to male wires
×1

Software apps and online services

Arduino IDE

Story

Read more

Schematics

Connection of PIR sensor with Arduino

This code is just for looking at the pins of PIR sensor. ONLY DO CONNECTION AS COMMENTED IN THE CODE.

Code

Upload this code and see results by simply coming in front of PIR sensor

C/C++
I have given comments in the code. DO CONNECTION ONLY AS COMMENTED IN THE CODE.
int sensorPin = 3; // connect PIR sensor to digital pin 3
int ledPin = 4;    // connect LED to digital pin 4
int buzzerPin = 5; // connect buzzer to digital pin 5

void setup() {
  Serial.begin(9600);
  pinMode(sensorPin, INPUT); 
  pinMode(ledPin, OUTPUT);      // declare all pins as OUTPUT
  pinMode(buzzerPin, OUTPUT);  
  

  
}

void loop() {
  
  if(digitalRead(sensorPin) == HIGH)   // if the value of pulse from PIR sensor is HIGH then LED will glow and buzzer will ring
  {
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    Serial.println("THERE IS SOME MOTION IN FRONT OF SENSOR");
  }
  else                                 
  {
    digitalWrite(ledPin, LOW);                     // if the value of pulse from PIR sensor is LOW then LED will not glow and buzzer
    digitalWrite(buzzerPin, LOW);                  // will not ring!
    Serial.println("THERE IS NO MOTION IN FRONT OF SENSOR");
  }
}

Credits

rudraksh2008

rudraksh2008

4 projects • 1 follower

Comments