How to use Mini PIR motion sensor with Arduino | HC-SR501

Mini PIR motion sensor with Arduino | HC-SR501

Hello, welcome back. In this tutorial, we will learn what is the mini PIR motion sensor and how to use it with Arduino. This sensor is also known as HC-SR 505. We have already explained in a previous tutorial how the HC-SR501 PIR sensor works with the Arduino, and this is very small compared to that sensor. But, these two sensors work in the same way. We can use these sensors mainly for projects such as security systems, automatic light switches, industrial automation, body induction toys. If you want to visit the HC-SR501 tutorial, click this link.

Mini PIR motion sensor(Passive Infrared Sensor)

This sensor is mainly used to detect motions. Also, it is very small and we can buy this sensor at a lower price. This sensor is designed based on infrared technology. That is, an infrared rays detection sensor is included in this sensor module. The spherical lens here can detect a wide range of rays. That is, rays at a distance of 3m can be detected. Also, when an infrared ray change occurs, we can get it as a digital signal through this sensor. A potential of 4.5v to 20v is required to activate this sensor.

Other specification of this sensor

  • Operating voltage range: DC4.5-20V
  • Level output: Gao 3.3V / Low 0V
  • Induction angle: <100 degrees cone angle
  • Sensing distance: 3 meters
  • Delay Time: The default 8S + -30%
  • Working temperature: -20 to +80 degrees

The PIN structure of this sensor

Mini PIR motion sensor with Arduino | HC-SR501

OK, let’s learn how to work this sensor with Arduino. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, connect these components. For that, use the circuit diagram below.

Mini PIR motion sensor with Arduino | HC-SR501

Step 3

Thirdly, let’s creates the program for this project. It is as follows.

  • The complete program of this project – download
/*HC-SR505 Mini PIR sensor with Arduino
 * https://srituhobby.com
 */
 
#define sensor 2
#define LED 3
void setup() {
  Serial.begin(9600);
  pinMode(sensor, INPUT);
  pinMode(LED, OUTPUT);
}

void loop() {
  bool value = digitalRead(sensor);

  (value == 1) ? digitalWrite(LED, HIGH) : digitalWrite(LED, LOW);
  Serial.println(value);

}

Code explanation

First, the sensor pin and the LED pin are defined.

#define sensor 2
#define LED 3

In the setup function, the sensor pin is set as an input pin and the LED pin is set as an output pin.

void setup() {
  Serial.begin(9600);
  pinMode(sensor, INPUT);
  pinMode(LED, OUTPUT);
}

In the loop function,

void loop() {
//Obtains sensor value and inserts it into the variable
  bool value = digitalRead(sensor);
//This value is checked using the IF condition. If the sensor value is 1, the turns on the LED. Otherwise, the LED is turned off
  (value == 1) ? digitalWrite(LED, HIGH) : digitalWrite(LED, LOW);
  Serial.println(value);

}

Step 4

Finally, select the board and port. After, upload this code to the Arduino board.

Ok, enjoy this project. The full video guide is given below. So, we will meet in the next tutorial.

How to use Mini PIR motion sensor with Arduino | HC-SR501

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *