Project - Motion Detection Alarm

Overview

In this project, we’ll build a PIR motion sensor system with an Arduino. When motion is detected, the LED will turn on.

SR602

Pasted image 20250129152943.png

The SR602 PIR sensor is a small, low-power motion detector module often used in hobbyist and DIY electronics projects. It is based on Passive Infrared (PIR) technology, meaning it detects motion by sensing changes in infrared radiation emitted by objects, such as humans or animals.

Key Features

  • Operating Voltage: 3.3V to 9V (commonly used at 3.3V or 5V).
  • Detection Range: Typically 3 to 7 meters, adjustable with a resistor.
  • Output: Digital signal (HIGH when motion is detected, LOW otherwise).
  • Detection Angle: Around 100°.
  • Quiescent Current: Very low, typically < 20 µA, making it suitable for battery-powered applications.
  • Time Delay: Fixed to approximately 2 seconds.
  • Compact Size: Ideal for space-constrained projects.

Pinout

  1. VCC: Power input (3.3v - 5v).
  2. OUT: Digital output (motion detected = HIGH, no motion = LOW).
  3. GND: Ground.

Wiring

Using the SR602 PIR sensor with an Arduino is a simple and effective way to create a motion detection system. Below is a step-by-step guide for wiring, programming, and running your Arduino with the SR602 PIR sensor.

1. Wiring the SR602 to Arduino

Connection Diagram:

SR602 PIR Sensor Arduino
VCC 5V
OUT GPIO 3
GND GND

Arduino Code

The Arduino will read the digital signal from the SR602 sensor’s OUT pin to determine whether motion is detected.

#define PIR_PIN 3 // Define the GPIO pin connected to SR602 OUT
#define LED_PIN 4  // Optional: Built-in LED on Arduino (GPIO 4)

void setup() {
	Serial.begin(9600);
	pinMode(PIR_PIN, INPUT);  // Set PIR_PIN as input
	pinMode(LED_PIN, OUTPUT); // Set LED_PIN as output
}

void loop() {
	if (digitalRead(PIR_PIN) == HIGH) {
		Serial.println("Motion Detected!");
		digitalWrite(LED_PIN, HIGH); // Turn on the LED if motion is detected
	} else {
		digitalWrite(LED_PIN, LOW);  // Turn off the LED if no motion is detected
	}

  delay(10); // Add a small delay to stabilize readings
}
C++

Code Explained

digitalRead(PIR_PIN)
C++

The SR602’s OUT pin outputs HIGH when motion is detected and LOW (0V) when no motion is detected. The Arduino reads this signal through the digitalRead() function.

if (digitalRead(PIR_PIN) == HIGH) {
		Serial.println("Motion Detected!");
		digitalWrite(LED_PIN, HIGH); // Turn on the LED if motion is detected
	}
C++

If motion is detected, the onboard LED (GPIO 22) turns on, and a message is printed to the Serial Monitor.

Testing the Setup

  1. Upload the code to the Arduino using the Arduino IDE.
  2. Open the Serial Monitor (Ctrl + Shift + M) and set the baud rate to 9600.
  3. Move your hand or body within the sensor’s range (approximately 3-7 meters), and observe the serial output or LED.
  4. The SR602 has a fixed time delay of about 2 seconds; once motion is detected, the output remains HIGH for 2 seconds before resetting to LOW.

Tips

If you experience noise in the output, add a small ceramic capacitor (e.g., 0.1 µF) between VCC and GND near the sensor to stabilize power.****

RELATED ARTICLES