0% found this document useful (0 votes)
97 views2 pages

PIR Sensor (HC-SR501) : Adafruit

Passive infrared (PIR) sensors detect motion based on infrared heat. They are commonly used to detect potential intruders or people. PIR sensors take 10-60 seconds to warm up after powering on, so avoid motion during that time. The schematic and code for using a PIR sensor with Arduino are provided. The code reads the PIR sensor pin and prints "Motion!" if motion is detected or "No motion" if not.

Uploaded by

red petals
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views2 pages

PIR Sensor (HC-SR501) : Adafruit

Passive infrared (PIR) sensors detect motion based on infrared heat. They are commonly used to detect potential intruders or people. PIR sensors take 10-60 seconds to warm up after powering on, so avoid motion during that time. The schematic and code for using a PIR sensor with Arduino are provided. The code reads the PIR sensor pin and prints "Motion!" if motion is detected or "No motion" if not.

Uploaded by

red petals
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PIR Sensor (HC-SR501)

Introduction

Passive Infra-Red (PIR) sensors are used to detect motion based on the infrared heat
in the surrounding area. This makes them a popular choice when building a system to
detect potential intruders or people in general. These sensors can take for 10-60
seconds to warm up, so try to avoid motion during that time.

Parts

Arduino
PIR Sensor
Wires

Schematic

Below is the schematic for using a PIR sensor. It is fairly simple.

Code

Adafruit has a really good tutorial for how these sensors are used and various projects
for them.

Below is the code for working with a PIR sensor. It should be noted that the PIR
sensor does not respond immediately when motion stops. This has to do with the two
potentiameters on the sensor.

Free Datasheet http://www.datasheet-pdf.com/


int pirPin = 8;
int val;

void setup() {
Serial.begin(9600);
}

void loop() {
val = digitalRead(pirPin); //read state of the PIR

if (val == LOW) {
Serial.println("No motion"); //if the value read is low, there
was no motion
}
else {
Serial.println("Motion!"); //if the value read was high, there
was motion
}

delay(1000);
}

Free Datasheet http://www.datasheet-pdf.com/

You might also like