Arduino uses human infrared sensor module hc-sr501

Source: Internet
Author: User

Through this article, you can learn the following: basic information and wiring method of the hc-sr501 sensor hc-sr501 jumper Select two time modes hc-sr501 simple function Experiment hc-sr501 sensor basic information and wiring method

The hc-sr501 is a pyroelectric-based body heat-release motion sensor that detects infrared rays emitted by humans or animals. The sensor module can detect 3 to 7 m range with two knob adjustment, 5 seconds to 5 minutes delay time, and can also select a single trigger and repeat trigger mode via jumper. hc-sr501 pin and control

hc-sr501 Pin and adjustment details refer to the table below, data from, translated by the author.

Pin and Control function
Time delay Adjustment For adjusting the length of time to maintain a high level output after detection of a move, the range can be adjusted from 5 seconds to 5 minutes
Sensing distance Adjustment For adjustment of detection range, adjustable range 3 m ~ 7 m
Detection mode conditions Selectable single detection mode and continuous detection mode
GND Grounding Pin
Vcc Connect the Power Pin
Output pin No move is detected as low, mobile output high is detected
time delay, distance adjustment method

Time delay Adjustment
The Fresnel lens is facing up, the left knob adjusts the time delay, the delay time is increased clockwise, and the delay time is reduced in the counterclockwise direction.

Distance adjustment
The Fresnel lens is facing up, the right knob adjusts the sensing distance, the clockwise direction decreases the distance, and the counterclockwise direction increases the distance.

detection mode jumper adjustment

As shown above, the knob next to the three pins for the detection mode selection jumper, the jumper cap inserted in the above figure two pins, that is, a single detection mode, the bottom two pins for continuous detection mode.

One-time detection mode
The sensor detects a move, and when the output is high, the delay period is over, and the output automatically changes from high to low.
Continuous detection mode
When the sensor detects a move and the output is high, if the human body continues to move within the detection range, the sensor remains high, knowing that the person leaves before the delay turns the high level to low.
The difference between the two detection modes, after detecting the movement trigger, if the human body continues to move, whether the continuous output high level. hc-sr501 simple function Experiment

Next, we will try to complete a simple experiment to use this sensor.
First we need the following originals:

name Quantity
Arduino UNO 1
hc-sr501 1
Wire Some

Then, connect the Arduino to the sensor as shown below:

Next, compile the following program onto the Arduino.

int ledpin =;
int pirpin = 7;

int pirvalue;
int sec = 0;

void Setup ()
    Pinmode (Ledpin, OUTPUT);
    Pinmode (Pirpin, INPUT);

    Digitalwrite (Ledpin, low);
    Serial.begin (9600);

void Loop ()
    pirvalue = Digitalread (pirpin);
    Digitalwrite (Ledpin, pirvalue);
    The following note allows you to observe the sensor output status
    //sec + = 1;
    Serial.print ("Second:");
    Serial.print (sec);
    Serial.print ("PIR value:");
    Serial.print (pirvalue);
    Serial.print (' \ n ');
    Delay (+);

After completing the above steps, power the Arduino, and if everything is OK, the LEDs on the Arduino will illuminate when moving in front of the sensor, and then you can experience the difference between different detection modes by changing the jumper connection. Summary

This article we understand the use of hc-sr501 human motion sensor and the adjustment of wiring methods, and then analyze and understand the difference between the two different detection modes, and finally completed a small experiment experience using the human body mobile sensor function. References

Arduino hc-sr501 Motion Sensor Tutorial
Full version hc-sr501 human sensor module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.