Logo

PIR Sensor Interfacing Using Arduino – Simple Steps

PIR Sensor Interfacing Using Arduino – Simple Steps - Experiment Image

Written By - Pari Sharma

Have you ever wondered how to alert your Arduino when someone is skulking? The PIR sensor is the key, though! It's similar to adding eyes to your Arduino so it can recognize movement. Wondering how it operates? Simply connect it, and your Arduino will begin to detect movement like a nighttime ninja!
What if we now add some interest to the situation? When your Arduino senses a cunning invader, how do you think it will respond? You can activate lights, alarms, or even a robot rebellion with a PIR sensor! Let's explore the wonders of motion detection and discover how everything works together. Are you ready?

An Overview of PIR Sensor and Arduino

Passive infrared (PIR) sensors pick up infrared radiation from objects, especially live things like people and animals. As heat signatures travel over its detection range, it detects changes in the ambient temperature and detects motion. The sensor compares the radiation emitted to a reference using two infrared sensors. The sensor signals the Arduino to perform an action, like as turning on lights or sounding an alert, when a moving item passes inside its range of vision. Automation and security systems make extensive use of it.

PIR Sensor Interfacing Using Arduino – Simple Steps - Specifications

Pin Diagram

PIR Sensor Interfacing Using Arduino – Simple Steps -  Pin Diagram

Circuit Diagram

PIR Sensor Interfacing Using Arduino – Simple Steps - Circuit Diagram

Steps

1. Connect the PIR sensor’s VCC pin to the 5V pin on the Arduino.

2. Connect the PIR sensor’s GND pin to the GND pin on the Arduino.

3. Connect the OUT pin of the PIR sensor to a digital pin (e.g., pin 2) on the Arduino.

4. Insert the PIR sensor in a suitable position where it can detect motion.

5. Write code to monitor the sensor's OUT pin for motion detection.

6. Upload the code to the Arduino and test by triggering movement in front of the sensor.

Code

1
2 int PIR PIN = 4;
3 void setup() 
4{ 
5
6       serial.begin(9600); 
7       pinMode(PIR PIN, INPUT); 
8       delay(1000); 
9      
10} 
11Void loop()
12{ 
13       int motionDetected = digitalRead(PIR PIN); 
14        if (motionDetected = = HIGH) 
15         {
16
17            serial.println(“Motion detected!);   
18         }
19          delay(500); 
20             
21
22

Conclusion

To sum up, the PIR sensor gives your Arduino extraordinary senses, enabling it to detect every sly movement! It's a neat way to add some clever functionality, whether you're using it to activate lights when you enter a room or to sound an alert when someone attempts to enter covertly. Therefore, simply connect a PIR sensor and let the motion detecting magic happen the next time you need your Arduino to behave like a spy!