PIR Sensor with Arduino UNO

PIR Sensor with Arduino UNO
Atribot team

Written by

Atribot team

Last updated

June 18, 2026

Introduction

The PIR (Passive Infrared) Sensor is a popular motion detection sensor used in Arduino projects. It detects infrared radiation emitted by humans and animals, making it ideal for security systems, automatic lighting, smart home automation, and motion-triggered devices.

In this tutorial, you will learn how to interface a PIR Sensor with an Arduino UNO, upload the code, and detect motion using the Serial Monitor. By the end of this guide, you'll understand how PIR sensors work and how they can be used in motion detection applications.

Components Required

Swipe right to view full table
Item NameQtyAction
1
PIR Sensor
1
USB Cable
1
Breadboard
1
Jumper Wires
3

Tools Required

Swipe right to view full table
Item NameAction
Soldering Iron
Screwdriver

Software Required

Swipe right to view full table
Item NameAction
Arduio IDE

Circuit Diagram

PIR Sensor with Arduino UNO Circuit Connection
PIR Sensor with Arduino UNO Circuit Connection

Source Code

PIR_Sensor_with_Arduino_UNO.inocpp
const int pirPin = 2;

void setup()
{
  pinMode(pirPin, INPUT);

  Serial.begin(9600);
}

void loop()
{
  int motionState = digitalRead(pirPin);

  if(motionState == HIGH)
  {
    Serial.println("Motion Detected");
  }
  else
  {
    Serial.println("No Motion");
  }

  delay(500);
}

Step by Step Instructions

Step 1: Connect the PIR Sensor

Make the following connections:

Swipe right to view full table

PIR Sensor

Arduino UNO

VCC

5V

GND

GND

OUT

D2

Step 2: Open Arduino IDE

  1. Launch Arduino IDE.

  2. Connect Arduino UNO using USB.

  3. Select:

    • Board → Arduino UNO

    • Port → Correct COM Port

Step 3: Create a New Sketch

Create a new Arduino sketch and paste the provided code.

Step 4: Verify the Code

Click the Verify button to check for syntax errors.

Step 5: Upload the Code

Click Upload and wait for the upload process to complete successfully.

Step 6: Open Serial Monitor

  1. Open Serial Monitor.

  2. Set the baud rate to 9600.

  3. Wait 30–60 seconds for the PIR sensor to stabilize.

  4. Move your hand or walk in front of the sensor.

The Serial Monitor will display motion detection messages.

Expected Output

When motion is detected:

Motion Detected
Motion Detected
Motion Detected

When no movement is present:

No Motion
No Motion
No Motion

Conclusion

In this tutorial, you learned how to interface a PIR Sensor with Arduino UNO and detect motion using infrared sensing technology. This basic setup can be used in various Arduino projects that require human presence detection and motion sensing.