PIR Sensor Module HC-SR501 Quickstart Guide

The PIR Motion Sensor is an affordable sensor for commonly used for motion detection. This is possible by detecting changes in the infrared levels in the environment, a common scene when there is motion in the environment. The sensor has only three pins for usage, making it a good starting sensor for electronic enthusiasts and beginners.

The PIR sensor only gives out HIGH or LOW signal output, which means that no serial communications is needed. Simply plug to your microcontroller, read the data and create a response for the two conditions.


  • Working Voltage: DC 5V -15V
  • Signal Output: 0 (no movement), 3.3V (movement detected)
  • Delay Time: Adjustable (18 – 300 seconds)
  • Lock time: 0.2 seconds
  • Trigger Methods: L- disable repeat trigger, H – enable repeat trigger
  • Sensing range: less than 120°, within 7 meters
  • Dimension: 32*24 mm


For this quickstart guide, we will need the following materials. Click on the image for more information.

  • Arduino Uno
  • PIR Motion Sensor HCSR501 Line Follower Sensor Board (1 channel)
  • Male – Female Connecting Wires


The line follower sensor has three pins: VCC, GND and Out.


INPUT Description
GND To be connected to the GND pin in a microcontroller.
VCC Supplies power to the module. Could be connected to a +5V pin.
Out Sends a high or low pulse signal to indicate whether there is a black or a white color detected.

The PIR has two detection modes: single cycle mode and retriggerable mode. The single cycle mode (L) detects a single movement only, and stays on until the specified time. Any movement done after trigger on single cycle mode is not detected by the PIR sensor. On retriggerable mode, any movement done after trigger resets the time the sensor is on. To set to retriggerable mode, move the jumper header to repeat trigger pin. For single cycle trigger, move header to single trigger pin.

To adjust the duration of the ON-period of the PIR, rotating the potentiometer clockwise increases the delay by 5 minutes, while rotating counterclockwise decreases it to 18 seconds. Sensitivity increases up to 7 meters on clockwise rotation, and up to 3 meters, counterclockwise.


Connect the line sensor to the Arduino Board according to the table below:

Line/Obstacle Sensor —> Arduino

VCC —> 5V




On a blank sketch in the Arduino IDE program, code the code below:

/*test program for HC-SR501 Motion Sensor*/

int PIRpin = 8; // input pin for arduino to read motion sensor logic high data
int val;

void setup()
  pinMode(13, OUTPUT);

void loop()
  val = digitalRead(PIRpin);

  if (val == LOW)
    Serial.println("No Motion");
    digitalWrite(13, LOW);
    Serial.println("Motion Detected!");
    digitalWrite(13, HIGH);

Compile the code, and upload it into the Arduino Board. Open Serial Monitor, and set baud rate to “9600, BOTH NL & CR”.


After uploading the code open your Arduino Serial Terminal. It will display if Motion is detected or No motion detected.

By placing and waving your hand or “body” in front of the motion sensor (with around 5 meter distance range in front of the sensor) the LED on the Arduino board will light up and in the Arduino Serial Terminal a “Motion Detected!” message will show. If no hand or body figure is moving in front of the sensor the LED on the Arduino will not light up and the Serial Terminal will display a “No Motion” message.