Skip to main content

How to the Use the Mini PIR Sensor Module (HC-SR505)

The mini PIR sensor module is a sensor that can detect motion through the use of infrared light. In this guide, we will be using the Mini PIR Sensor Module (HC-SR505) that is found in our shop.

Partsā€‹

Wiring Guideā€‹

Step 1: Connect the PIR sensor pins to the Arduino

SensorArduino
+5V
SPin 3
-GND

Programmingā€‹

Step 1: First of all, define the pin number that is connected to the signal output

int signalPin = 3;

Step 2: Start the serial monitor and activate the pin that is connected to the signal output

void setup(){
Serial.begin(9600);
pinMode(signalPin, INPUT);
}

Step 3: Write down some code that will print on the serial monitor whether the sensor senses movement or not

void loop(){
if(digitalRead(signalPin)==HIGH){
Serial.println("Movement detected");
}else{
Serial.println("Did not detect movement");
}
delay(1000);
}

Full Codeā€‹

int signalPin = 3;

void setup(){
Serial.begin(9600);
pinMode(signalPin, INPUT);
}

void loop(){
if(digitalRead(signalPin)==HIGH){
Serial.println("Movement detected");
}else{
Serial.println("Did not detect movement");
}
delay(1000);
}

Outputā€‹

Serial Monitor