The PIR Motion Sensor is a Passive Infrared sensor that detects motion by measuring changes in the infrared levels emitted by objects in its field of view. When a living being, such as a human or animal, enters the sensor's range, it detects the change in infrared radiation and can trigger a response. This sensor is widely used in security systems, automatic lighting control, and various automation projects due to its non-intrusive nature and ease of integration with microcontroller platforms like Arduino.
Pin Name | Description |
---|---|
VCC | Power supply (5V-12V DC) |
OUT | Digital output signal (High/Low) |
GND | Ground |
// PIR Motion Sensor Example Code
int pirPin = 2; // Digital pin connected to the PIR sensor's output
int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(pirPin, INPUT); // Initialize the PIR pin as an input
pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
int pirValue = digitalRead(pirPin); // Read the value from the PIR sensor
if (pirValue == HIGH) { // Check if the PIR sensor is detecting motion
digitalWrite(ledPin, HIGH); // Turn on the LED
Serial.println("Motion detected!");
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
Serial.println("No motion detected.");
}
delay(1000); // Wait for 1 second before reading again
}
Q: How long does the sensor output stay high after detecting motion? A: This can vary based on the sensor model and settings of the time delay potentiometer.
Q: Can the sensor detect motion through walls or glass? A: No, the sensor cannot detect motion through solid objects.
Q: Is the sensor waterproof? A: Most PIR sensors are not waterproof unless specified by the manufacturer. It is recommended to use them indoors or in a waterproof enclosure if used outside.
Q: How can I adjust the range and sensitivity of the sensor? A: Some models come with potentiometers that allow you to adjust the sensitivity and the time the output signal stays high after detection.