✨ Use RCAPP and get 5% off 👇
Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

Interfacing PIR Motion Sensor with Arduino

Interfacing PIR Motion Sensor with Arduino
-
Written By - Robocraze -
📅 Updated on 27 Nov 2025
Summarize with AI
✅ Prompt copied

Summary

Motion detection has become an essential component in modern electronics, from security systems to automated lighting. The PIR (Passive Infrared) sensor offers a simple yet effective way to detect movement in its vicinity.

When paired with Arduino, it creates a powerful combination for building intelligent, responsive systems. This guide will walk you through everything you need to know about connecting and programming a PIR sensor with Arduino.

Interfacing PIR Motion Sensor with Arduino - Cover image

What Is a PIR Motion Sensor?

The PIR Motion Sensor monitors the infrared radiation levels in its field of view, waiting for something warm-blooded, like a human or animal, to pass by. The moment it detects a change in infrared energy, it springs into action.

Unlike other kinds of sensors, the PIR Motion sensor doesn't emit anything. There are no infrared beams or radio waves shooting out. It just passively observes. That's where the "Passive" in PIR comes from. Instead, it detects using the pyroelectric material.

PIR Motion Sensor

The pyroelectric material generates electricity when exposed to heat. When you walk past it, your body heat creates a rapid change in the infrared radiation pattern, and the sensor picks up on this shift. 

Most PIR sensors come packaged in white dome-shaped modules. Inside that dome sits a Fresnel lens. These segmented, faceted lenses look like dozens of tiny bubbles.

This lens divides the detection area into multiple zones, making the sensor far more sensitive to movement across its field rather than just straight-on approaches. 

The detection range typically extends from 3 to 7 meters. The field of view usually spans around 120 degrees, creating a cone-shaped detection zone. Some sensors also include adjustable potentiometers that let you fine-tune sensitivity and the duration the output signal stays high after detecting motion. 

Components and Supplies

Original Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -RobocrazeOriginal Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -Robocraze

    Arduino Uno R3 Original

    Arduino UNO R3 Original The Arduino Uno R3 is a microcontroller board based on the ATmega328P chip and is widely recognized as the best original Arduino Uno board for beginners and projects. This board has 14 digital I/O pins (6 support PWM), 6 analog...
    Rs 1,843/-
    Rs 1,843/-
    Rs 2,649/-
    Save Rs 806/-
    Arduino Nano Original – Classic ATmega328 board for compact projects. -Original Arduino Board -RobocrazeArduino Nano Original A000005

      Arduino Nano Original A000005

      Arduino Nano Original A000005 The Arduino Nano is a compact, open-source development board based on ATmega328P, an 8-bit AVR microcontroller. It has 14 digital I/O pins, 8 analog input pins with 10-bit resolution, 2 reset pins, and 6 power pins, making it perfect for space-constrained...
      Rs 1,585/-
      Rs 1,585/-
      Rs 2,299/-
      Save Rs 714/-
      HCSR501 PIR Motion Sensor (Passive Infrared Sensor)HCSR501 PIR Motion Sensor (Passive Infrared Sensor)

        HCSR501 PIR Motion Sensor (Passive Infrared Sensor)

        HCSR501 PIR Motion Sensor The HC-SR501 PIR Motion Sensor Module is used to detect the motion of a human body within the sensor’s range. It is often referred to as a PIR sensor, “Pyroelectric”, “Passive Infrared” and “IR motion sensor” device. This PIR motion...
        Rs 64/-
        Rs 64/-
        Rs 85/-
        Save Rs 21/-
        10mm Bright Green LED - 10pcs Pack10mm Bright Green LED - 10pcs Pack

          10mm Bright Green LED - 10pcs Pack

          10mm Bright Green LED - 10pcs Pack The 10mm Bright Green LED - 10pcs Pack includes super bright LEDs that shine with a wide beam. They are perfect for projects, lighting up models, headlamps, spotlights, car lighting, and more. These LEDs use low power...
          Rs 50/-
          Rs 50/-
          Rs 69/-
          Save Rs 19/-
          220 Ohm Resistor (10PC) – Voltage regulation resistors. -Basic Components -Robocraze220 Ohm Resistor (10PC) – Voltage regulation resistors. -Basic Components -Robocraze

          220 Ohm Resistor - (Pack of 10)

          220 Ohm Resistor - (Pack of 10) A 220-ohm resistor is an electronic component that is used to resist the flow of electricity in a circuit. Resistors are used in a wide variety of electronic circuits to control the flow of current and protect...
          Rs 9/-
          Rs 9/-
          Rs 15/-
          Save Rs 6/-
          170 Points Mini Breadboard – Compact solderless breadboard for quick prototyping. Electronic Components - Robocraze170 Points Mini Breadboard – Compact solderless breadboard for quick prototyping. Electronic Components - Robocraze

            170 Points Mini Breadboard

            170 Points Mini Breadboard This 170 Points Mini Breadboard is the ideal companion for seamless electronics prototyping, designed to provide a hassle-free experience. With a 2x17 row layout and a total of 170 pins, this prototyping breadboard offers abundant space to create and test...
            Rs 20/-
            Rs 20/-
            Rs 29/-
            Save Rs 9/-
            3M USB to Micro USB Cable Black3M USB to Micro USB Cable Black – High-quality Arduino USB Cable for fast charging & data transfer. -Robocraze

              3M USB to Micro USB Cable Black

              3M USB to Micro USB Cable Black - (Compatible with Smart Phones, Tablets, Power Bank, Black) Tired of short cables that limit where you can use your devices? The 3M USB to Micro USB Cable in Black is here to help. It’s 3 meters...
              Rs 129/-
              Rs 129/-
              Rs 199/-
              Save Rs 70/-

              Working Principle of a PIR Sensor 

              The sensor contains two infrared-sensitive elements positioned side by side. In a stable environment with no movement, both elements receive the same amount of infrared radiation, and their outputs cancel each other out. The sensor remains in a low state. 

              When motion occurs, the scenario changes dramatically. Imagine someone walking across the sensor's field of view. First, one sensing element detects the infrared signature of the moving person, while the other doesn't, creating an imbalance.

              As the person continues moving, the second element picks up the heat signature. This differential change triggers the sensor's internal comparator circuit, which then drives the output pin high. 

              The sensor includes built-in signal processing circuitry. This typically consists of: 

              • A high-gain operational amplifier that boosts the tiny electrical signals from the pyroelectric elements 
              • A comparator that converts the analog signal into a digital output 
              • Timing circuitry that controls how long the output remains high 
              • Optional retriggering logic that can extend the detection signal if motion continues 

              Most sensors operate in one of two modes. In repeatable trigger mode, the output stays high as long as motion continues within the detection zone. In non-repeatable trigger mode, the output goes high for a preset time and won't trigger again until that period expires, regardless of continued motion. 

              Components Required for This Project 

              Make sure you have the following components before you get started with the project: 

              Optional but recommended components include a buzzer for audio alerts and a relay module if you plan to switch higher-voltage devices. You can build a functional motion detection using Arduino with just a handful of inexpensive components available at any electronics store. 

              Circuit Diagram for Interfacing PIR Sensor with Arduino

              Circuit Diagram for Interfacing PIR Sensor with Arduino

              Let's break down what's happening in this circuit, because understanding the connections makes building it ten times easier. 

              Looking at the image, you've got two main players here: the HC-SR501 PIR sensor sitting at the top and the Arduino Uno board below it. Three wires connect them together and that's all it takes to get motion detection working. 

              Looking at this circuit, you've got the HC-SR501 PIR sensor at the top connected to the Arduino Uno below it. 

              Here's what's happening with the three wires: 

              • Black wire (GND): Runs from the sensor's left pin to Arduino's ground—this completes the circuit 
              • White wire (VCC): Middle pin connects to Arduino's 5V output, powering up the sensor 
              • Red wire (Signal): Right pin goes to digital pin 7, sending HIGH when motion's detected 

              PIR Sensor Pin Configuration and Connections 

              The HC-SR501 module keeps things simple with just three pins to work with. Once you know what each one does, you're halfway there. 

              The three pins break down like this: 

              • VCC (Power): Supplies operating voltage between 4.5V to 12V. Most projects use the Arduino's 5V output, which works perfectly 
              • GND (Ground): Completes the electrical circuit. Connect this to any Arduino ground pin 
              • OUT (Signal): The digital output pin that goes HIGH (3.3-5V) when motion's detected, LOW otherwise

              Arduino Code for PIR Motion Sensor 

              The code that brings your Arduino with PIR Motion Sensor to life is quite simple. Here's a complete, working program with detailed explanations:

              
              const int pirPin = 2;        // PIR sensor output connected to pin 2 
              const int ledPin = 13;       // LED connected to pin 13 
              int pirState = LOW;          // Start assuming no motion detected 
              int val = 0;                 // Variable to store sensor status 
               
              void setup() { 
                pinMode(ledPin, OUTPUT);   // Set LED pin as output 
                pinMode(pirPin, INPUT);    // Set PIR pin as input 
                Serial.begin(9600);        // Initialize serial communication 
                delay(2000);               // Give sensor time to stabilize 
                Serial.println("PIR Sensor Ready"); 
              } 
               
              void loop() { 
                val = digitalRead(pirPin); // Read the sensor output 
                 
                if (val == HIGH) {         // Motion detected 
                  digitalWrite(ledPin, HIGH); 
                   
                  if (pirState == LOW) { 
                    Serial.println("Motion Detected!"); 
                    pirState = HIGH; 
                  } 
                }  
                else {                     // No motion 
                  digitalWrite(ledPin, LOW); 
                   
                  if (pirState == HIGH) { 
                    Serial.println("Motion Ended"); 
                    pirState = LOW; 
                  } 
                } 
              }
              

              The code architecture follows a simple but effective pattern. During setup, pin modes are configured and the serial monitor initializes for debugging. The 2-second delay allows the PIR sensor to calibrate itself—critical for accurate operation.

              The main loop continuously polls the PIR sensor's digital output. When motion is detected (HIGH signal), the LED illuminates and a message prints to the serial monitor. The pirState variable prevents flooding the serial monitor with repeated messages while motion continues. 

              You can enhance this basic code in numerous ways. Adding a buzzer creates an audible alarm. Implementing a relay module allows controlling lights, fans, or other AC-powered devices.

              For more sophisticated applications, consider adding a timer that sends notifications if motion is detected during specific hours, or integrate multiple sensors to cover larger areas. 

              The serial monitor output provides valuable debugging information. Open it through the Arduino IDE (Tools → Serial Monitor) and set the baud rate to 9600. You'll see real-time status updates showing exactly when motion starts and stops, helping troubleshoot any detection issues.

               

               

              Conclusion

              Building a motion detection system by interfacing a PIR sensor with Arduino opens doors to countless practical applications. From energy-efficient automatic lighting to security systems, the possibilities extend only as far as your imagination.

              The straightforward hardware connections and simple code make this project accessible to beginners while providing enough flexibility for advanced implementations. With this foundation, you're equipped to create responsive, intelligent systems that react to human presence.

              Excerpt

              Learn how to connect and program a PIR sensor with Arduino to create intelligent, responsive systems. A simple guide for beginners to get started.

              Frequently Asked Questions

              1. Can a PIR sensor detect through glass or walls?  

              No, PIR sensors cannot see through glass, walls, or other solid barriers. They detect infrared radiation, which glass and walls block. The heat signature must travel unobstructed to the sensor's lens. This actually makes them useful for window-mounted security applications—they won't falsely trigger from outdoor heat sources on the other side of glass.

              2. Can I use multiple PIR sensors with one Arduino board?  

              Absolutely. An Arduino Uno has multiple digital input pins, so you can connect several PIR sensors simultaneously. Each sensor connects to a different digital pin—sensor one to pin 2, sensor two to pin 3, and so on. Your code simply reads all pins in the loop function. This creates multi-zone motion detection across larger areas or different rooms.

              3. Does a PIR motion sensor work in the dark?  

              Yes, PIR sensors work perfectly in complete darkness. They detect infrared heat radiation, not visible light. Whether it's pitch black or bright daylight, the sensor responds identically to heat signatures. This makes them ideal for security systems, nighttime monitoring, and automatic lighting that needs to work 24/7 without depending on ambient light conditions.

              4. How do I prevent false triggering of a PIR sensor?  

              Reduce false triggers by adjusting the sensitivity and time delay potentiometers. Lower sensitivity prevents picking up minor heat fluctuations from air vents or pets. Increase the delay time so the sensor doesn't re-trigger too quickly. Allow the sensor 30-60 seconds to stabilize after power-on. Position it away from heat sources like radiators, sunlight, or air conditioning units that can cause spurious activations.

              5. Can a PIR sensor detect animals or only humans?  

              PIR sensors detect any warm-blooded moving object like humans, dogs, cats, birds etc. They respond to infrared heat signatures, not species. A small mouse generates less detectable heat than a large dog, affecting range. If you need human-only detection, you'd need additional logic or a different sensor type. For most applications, this multi-detection capability is actually beneficial for comprehensive motion monitoring.

              Prev Post
              Next Post

              Leave a comment

              Please note, comments need to be approved before they are published.

              Thanks for subscribing!

              This email has been registered!

              Shop the look

              Choose Options

              Edit Option
              Back In Stock Notification
              Compare
              Product SKU Description Collection Availability Product Type Other Details

              Choose Options

              this is just a warning
              Login
              Shopping Cart
              0 items
              FREE SHIPPING!
              ₹100 OFF
              ₹200 OFF
              ₹999
              ₹2500
              ₹4900
              WhatsApp Chat Chat