A PIR (Passive Infrared) Sensor detects changes in infrared radiation, which occurs when a warm body (like a human) moves in its field of view. It's the same technology used in commercial motion-activated lights and alarms.
The sensor contains a pyroelectric crystal that generates voltage when heated or cooled. A Fresnel lens in front focuses IR energy onto the sensor. When a person walks by, the sudden change in IR triggers an output signal.
| PIR Pin | Arduino Pin | | :--- | :--- | | VCC | 5V | | GND | GND | | OUT | D2 |
```cpp int pirPin = 2; int buzzerPin = 8;
void setup() { pinMode(pirPin, INPUT); pinMode(buzzerPin, OUTPUT); delay(30000); // Allow PIR to calibrate (30 seconds) }
void loop() { if (digitalRead(pirPin) == HIGH) { digitalWrite(buzzerPin, HIGH); delay(5000); // Alarm for 5 seconds digitalWrite(buzzerPin, LOW); } } ```
The HC-SR501 has two potentiometers:
Get started with the PIR Motion Sensor Alarm Using Arduino kit!
Explore our collection of DIY kits and components. All project components mentioned in this guide are available in our store.
Browse All Projects