A Passive Infrared (PIR) or Motion Sensor is an electronic device that detects the presence of humans or animals by sensing the infrared (IR) light emitted from their bodies. These sensors are widely used in security systems, lighting controls, and home automation systems due to their ability to detect motion through changes in heat radiation.
Pin Name | Description |
---|---|
VCC | Power supply input (5V to 12V DC) |
OUT | Digital output signal (High/Low) |
GND | Ground connection |
// PIR Motion Sensor with Arduino UNO
int PIRPin = 2; // Connect PIR sensor's OUT pin to digital pin 2
int LEDPin = 13; // Onboard LED connected to digital pin 13
int motionState = LOW; // Variable for reading PIR status
void setup() {
pinMode(PIRPin, INPUT); // Initialize PIR sensor pin as input
pinMode(LEDPin, OUTPUT); // Initialize LED pin as output
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
motionState = digitalRead(PIRPin); // Read PIR sensor's output
if (motionState == HIGH) { // Check if motion is detected
digitalWrite(LEDPin, HIGH); // Turn on LED
Serial.println("Motion detected!");
delay(1000); // Wait for 1 second
} else {
digitalWrite(LEDPin, LOW); // Turn off LED
Serial.println("No motion.");
}
}
Q: Can the PIR sensor detect motion through walls or glass? A: No, PIR sensors cannot detect motion through walls or glass as they rely on detecting changes in IR radiation from objects in their line of sight.
Q: How long does it take for the PIR sensor to stabilize after being powered on? A: It typically takes between 10 to 60 seconds for the PIR sensor to stabilize and calibrate to the ambient IR levels in the environment.
Q: Is it possible to adjust the range and sensitivity of the PIR sensor? A: Many PIR sensor modules come with potentiometers that allow you to adjust the sensitivity and time delay. Refer to the specific module's datasheet for guidance.