The HC-SR505 Mini PIR (Passive Infrared) Motion Sensing Module is a compact, low-power sensor capable of detecting the presence of humans or animals by sensing the infrared radiation they emit. This module is widely used in various applications such as security systems, automatic lighting, and home automation projects due to its small form factor and ease of use.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply input (4.5V to 20V) |
2 | OUT | Output signal (High/Low) |
3 | GND | Ground connection |
// Define the PIR motion sensor pin
const int PIRPin = 2; // Connect HC-SR505 OUT pin to Arduino pin 2
void setup() {
pinMode(PIRPin, INPUT); // Set the PIR pin as an INPUT
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int motionState = digitalRead(PIRPin); // Read the PIR sensor output
if (motionState == HIGH) {
// If motion is detected, output a message
Serial.println("Motion detected!");
// Add your code here to handle the motion event
} else {
// If no motion is detected, output a different message
Serial.println("No motion.");
}
delay(1000); // Wait for 1 second before reading again
}
Q: Can the HC-SR505 be used outdoors? A: The HC-SR505 is not waterproof and is best used indoors or in a protected outdoor environment.
Q: How can I adjust the delay time? A: The default delay time is approximately 8 seconds. To adjust it, you would need to replace the onboard timing resistor with one of a different value, which requires soldering and an understanding of the module's circuitry.
Q: Is it possible to power the HC-SR505 with a battery? A: Yes, as long as the battery voltage is within the 4.5V to 20V range, the HC-SR505 can be battery-powered.
Q: How can I reduce power consumption for battery-operated projects? A: You can reduce power consumption by using a lower supply voltage within the acceptable range and by minimizing the active time of any connected devices triggered by the sensor.