(PIR) Passive Infra-Red sensors are used to detect motion based on the infrared heat in the surrounding area. This makes them a popular choice when building a system to detect potential intruders or people in general. These sensors can take for 10-60 seconds to warm up, Also You can change the delay adjustment and sensitivity adjustment by changing the value of capacitors
e of HC-SR501 PIR Motion SensorArduino
SAMPLE CODE
// (HC-SR501) PIR Sensor
int PIRpin = 8; // PIR connected pin
int value;
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT); //For Led
}
void loop() {
value = digitalRead(PIRpin); //Read PIR state
if (value == LOW) {
Serial.println("No Movement");
digitalWrite (2, LOW);
}
else {
Serial.println("Movement!");
digitalWrite (2, HIGH);
}
delay(100); //Wait
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// (HC-SR501) PIR Sensor
int PIRpin = 8; // PIR connected pin
int value;
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT); //For Led
}
void loop() {
value = digitalRead(PIRpin); //Read PIR state
if (value == LOW) {
Serial.println("No Movement");
digitalWrite (2, LOW);
}
else {
Serial.println("Movement!");
digitalWrite (2, HIGH);
}
delay(100); //Wait
}
Información adicional