A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors.
All objects with a temperature above absolute zero emit heat energy in the form of radiation. Usually this radiation is invisible to the human eye because it radiates at infrared wavelengths, but it can be detected by electronic devices designed for such a purpose.
The term passive in this instance refers to the fact that PIR devices do not generate or radiate any energy for detection purposes. They work entirely by detecting the energy given off by other objects. PIR sensors don’t detect or measure “heat”; instead they detect the infrared radiation emitted or reflected from an object. An individual PIR sensor detects changes in the amount of infrared radiation impinging upon it, which varies depending on the temperature and surface characteristics of the objects in front of the sensor. When an object, such as a human, passes in front of the background, such as a wall, the temperature at that point in the sensor’s field of view will rise from room temperature to body temperature, and then back again. The sensor converts the resulting change in the incoming infrared radiation into a change in the output voltage, and this triggers the detection. Objects of similar temperature but different surface characteristics may also have a different infrared emission pattern, and thus moving them with respect to the background may trigger the detector as well. [source here].
The sensor used in this project is:
As you can see this sensor has 3 pins:
Vcc-5V arduino
GND-GND arduino
OUT- any digital pin arduino
Ok for the program we need to know what signal give the sensor on the digital output. You can measure with a voltmeter and see that, when the sensor detect moves put the pin in HIGH state.
You can use these sensor for a homemade light projector activate by moves or with a buzzer to make a sound alarm.
A buzzer you can use is sensor beep audion 9012 like in the picture below:
Like the PIR sensor it has 3 pins:
VCC-5 V arduino
GND-GND arduino
I/O-any digital input
Now to see how the PIR sensor work we have made this small program:
void setup() {
pinMode(13, OUTPUT); // initialize digital pin 13 as an output.
pinMode(2, INPUT); // initialize digital pin 2 as an input.
}
void loop() {
int x=digitalRead(2);
if(x==HIGH){ //if sensor detect moves
digitalWrite(13, HIGH);// put pin 13 in high state
}
else{
digitalWrite(13, LOW);// if the sensor don’t detect moves the pin 13 remain LOW
}
}
For buzzer we have this small program:
void setup() {
pinMode(9, OUTPUT);// initialize digital pin 9 as an output.
}
void loop() {
digitalWrite(9,HIGH); // if pin 9 is in HIGH state the buzzer not working
delay(1000);
digitalWrite(9, LOW); // if pin 9 is in LOW state the buzzer is working
delay(1000);
}
Now we have combined these two program in:
void setup() {
pinMode(9, OUTPUT);// initialize digital pin 9 as an output.
pinMode(2, INPUT);// initialize digital pin 2 as an input.
pinMode(13, OUTPUT);// initialize digital pin 13 as an output.
}
void loop() {
int x=digitalRead(2);// reading signal from PIR sensor
if(x==HIGH){ //if sensor detect moves
digitalWrite(9, LOW);// put pin 9 in low state, buzzer on
digitalWrite(13, HIGH);// LED from pin 13 on
}
else{
digitalWrite(9, HIGH);// if the sensor don’t detect moves the pin 9 is high, buzzer off
digitalWrite(13, LOW); //LED from pin 13 off
}
}
Please let us in the comment zone any suggestions that you think will improve the article!
If you like the article click the follow button from social media to stay in touch with us!
Below we have a small video without the buzzer, only with digital pin 13: