PIR Motion Detection Module

Introduction

This experiment demonstrates how to use a Passive Infrared (PIR) motion sensor to detect human movement and trigger an action.

PIR Motion Sensor

Components Needed

Circuit Setup

  1. Connect the PIR sensor’s VCC and GND pins to the 5V and GND on the Arduino.
  2. Connect the output pin of the PIR sensor to a digital input pin (e.g., D2) on the Arduino.

The PIR sensor detects motion in its field of view and sends a signal to the Arduino when movement is detected.

PIR Motion Circuit Setup

Code for PIR Motion Detection

Upload the following code to your Arduino to detect motion:


const int pirPin = 2;
const int ledPin = 13;

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int motionDetected = digitalRead(pirPin);
  if (motionDetected == HIGH) {
    digitalWrite(ledPin, HIGH); // Turn on LED if motion is detected
    Serial.println("Motion Detected!");
  } else {
    digitalWrite(ledPin, LOW);  // Turn off LED if no motion
    Serial.println("No Motion");
  }
  delay(500);
}
            

Explanation

The PIR sensor detects infrared radiation from moving objects, triggering a response (e.g., turning on an LED) when motion is detected.

Troubleshooting