2.31 PIR Module

Overview

In this lesson, you will learn how to use PIR Module. The PIR sensor detects infrared heat radiation or the presence of organisms that emit infrared heat radiation. This module is widely used in daily life for our intruder alarm and visiting prompt.

Fritzing Circuit

In this example, we can connect the pins of Sound Sensor Module to the pins of Mega 2560 Board directly, and we use digital pin 2 to read the signal of PIR Module. Connect the VCC of PIR Module to 5V, GND to GND, and OUT to digital pin NOTE: you can remove the PIR cover to see the pin mark.

../_images/image236.png

Schematic Diagram

../_images/image237.png

Code

Note

  • You can open the file 2.31_pirModule.ino under the path of sunfounder_vincent_kit_for_arduino\code\2.31_pirModule directly.

  • Or copy this code into Arduino IDE 1/2.

  • Or click Open Code to open it in Web Editor.

  • Then Upload the Code to the board.

After the codes are uploaded to the Mega2560 board, you can open the serial monitor to see the reading value of the pin. When PIR Module detects activity nearby, the serial monitor will display 「1」; otherwise, it will display 「0」. Check 1.4 Digital Read detail code explanation.

There are two potentiometers on the PIR module: one is to adjust sensitivity and the other is to adjust the detection distance. In order to make the PIR module work better, you need to try to adjust these two potentiometers.

Phenomenon Picture

../_images/image238.jpeg