A PIR Motion Sensor (Passive Infrared Sensor) is an electronic sensor that detects motion by measuring changes in infrared (IR) radiation in its surrounding environment. It is widely used in motion detection systems, security alarms, automatic lighting, and IoT projects.
How It Works
- All objects emit infrared radiation.
- The PIR sensor has two slots made of a special material sensitive to IR.
- When no motion occurs, the IR received by both slots is the same.
- When a warm object (like a human or animal) moves across the sensor's field of view, the amount of IR changes rapidly, triggering the sensor.
Key Features
- Type: Passive (does not emit energy, only detects)
- Detection Range: ~5m to 12m (depends on model)
- Detection Angle: ~110° to 180°
- Operating Voltage: 3.3V – 5V (common module: HC-SR501)
- Delay Time: Adjustable (usually 5 sec – 5 min)
- Trigger Modes:
- H (Repeatable): Output stays HIGH when motion continues
- L (Non-repeatable): Output resets after set delay
Pin Configuration (HC-SR501)
- VCC: 5V
- OUT: Digital Output (HIGH = motion detected)
- GND: Ground
Applications
- Motion-activated lighting
- Security alarms and intruder detection
- Automatic doors
- Smart home automation
- Energy-saving systems
Sample codes using Arduino
int pirPin = 2; // PIR sensor output pin connected to digital pin 2
int ledPin = 13; // Onboard LED or external LED
int pirState = LOW; // Default state (no motion)
int val = 0; // Variable to store PIR status
void setup() {
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Serial.println("PIR Motion Sensor Initialized");
}
void loop() {
val = digitalRead(pirPin); // Read PIR sensor
if (val == HIGH) {
digitalWrite(ledPin, HIGH);
if (pirState == LOW) {
Serial.println("Motion Detected!");
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW);
if (pirState == HIGH) {
Serial.println("Motion Ended!");
pirState = LOW;
}
}
}
Packages include: 1xPIR Sensor





















