The PIR HC-SR505 is a compact Passive Infrared (PIR) sensor designed for detecting motion through changes in infrared radiation levels within its detection range. This sensor is widely used in various applications such as automatic lighting, security systems, and home automation projects due to its small size and ease of use.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply input (4.5V to 20V) |
2 | OUT | Digital output signal (3.3V TTL) |
3 | GND | Ground connection |
// Define the PIR 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 motionStatus = digitalRead(PIRPin); // Read the PIR sensor output
if (motionStatus == HIGH) { // Check if motion is detected
Serial.println("Motion detected!");
// Add code here to handle motion detection event
} else {
Serial.println("No motion.");
// Add code here to handle no motion detected
}
delay(1000); // Wait for 1 second before reading again
}
Q: Can the HC-SR505 sensor detect motion through walls? A: No, the sensor cannot detect motion through walls as it relies on detecting changes in infrared radiation.
Q: How can I adjust the delay time of the sensor? A: The delay time can be adjusted by replacing the onboard resistor with a different value. However, this requires soldering and an understanding of the sensor's circuitry.
Q: Is it possible to power the HC-SR505 with a 3.3V supply? A: No, the minimum operating voltage for the HC-SR505 is 4.5V. Using a voltage lower than this may result in unreliable or no operation.