YwRobot PIR Motion Sensor Features
PIR or Passive Infra-Red sensors use a pair of pyroelectric sensors to detect heat energy in the surrounding environment. This module is used to detect motion of human or animals and has a range of up to 6 meters and 100 degrees viewing angle.
These sensors are usually used for security systems. This module features high sensitivity, high reliability and small size. Its LED turns on with motion detection, so it can work without connecting to a microcontroller.
YwRobot PIR Motion Sensor Pinout
This sensor has 3 pins:
- VCC: Module power supply – 5 V
- GND: Ground
- OUT: Digital output
You can see pinout of this module in the image below.
Required Materials
Hardware Components
Software Apps
Interfacing YwRobot PIR Motion Detection Sensor with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to YwRobot module. Connect wires accordingly.
Step 2: Code
Upload the following code to your Arduino.
/*
YwRobot-PIR-detection-Motion-Sensor
made on 20 oct 2020
by Amir Mohammad Shojaee @ Electropeak
Home
*/
const int Pin=2;
void setup() {
pinMode(Pin, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = digitalRead(Pin);
if(sensorValue==HIGH){
Serial.println("Detect Motion");
delay(5000);
while(sensorValue==LOW){}
}
}
In this sensor, the LED will turn on if motion is detected, and the output will be HIGH and last for about 5 seconds. In this program, the word “Detect Motion” appears in the Serial Monitor when the sensor detects motion.
The output is as follows.