HC-SR501 PIR Motion Sensor

From Epalsite Wiki
Jump to: navigation, search


PIR(Passive Infrared Detection)Motion Sensor is usually used in the security field. All people can output infrared light. When somebody moves in front of the module, then the infrared light variation will be detected by the module. For this sensor, it will output a high voltage when people moves in front of it.


  • Working Voltage:5V-20V
  • Static Current:65uA
  • Output: High 3.3V/ Low 0V
  • Delay Time: Regulatable, 0.3s-10minutes
  • Trigger Mode: "repeated trigger mode" or "unepeated trigger mode". The jumper is used to control the trigger mode. When the jumper cap is at the "L" position, the mode is set up as "unrepeated trigger mode", which means when the module is outputting an HIGH voltage because of human motion it will not be triggered again even if another human motion is detected. When the jumper cap is at the "H" position, the module is setup as "repeated trigger mode", which means the delaying time will be recalculated when a second human motion is detected during its delaying time.

The following picture shows some of its function definition.
PIR 功能图.jpg


The usage for this module is simple. It has 3 pins as are VCC, OUT, GND.

  • VCC should be connected to 5-20V voltage
  • OUT is the output of the module, should be connected to the input IO of MCU(Arduino or similar)
  • GND should be connected to the 0V of Arduino

In the following example we will use the PIR motion sensor to control the LED driven by D13.
Hardware Conection
Code Writing

 /*Note:This code is used for Arduino 1.0.1 or later*/
  PIR Controlled LED
  Turns on an LED when human motion is detected.
void setup() {                
  // initialize the digital pin as an output.
  pinMode(2, INPUT_PULLUP); 
  pinMode(13, OUTPUT);     

void loop() {
  int sensorValue = digitalRead(2);
  digitalWrite(13, HIGH);   // set the LED on
  digitalWrite(13, LOW);    // set the LED off