# PIR Motion Sensor

## Function introduction

This sensor allows you to detect the movement of animals, usually the movement of humans within its detection range. Just connect it to the NyBoard and program it, and when anyone moves within its detection range, the sensor will output a high potential on its **SIG** pin.

<figure><img src="/files/zGHRXDQ1cNoM3xC2WGvn" alt=""><figcaption></figcaption></figure>

## Hardware setup

Connecting to the NyBoard with wire as shown in the following picture:

<figure><img src="/files/PJYAqEdAf1rf34aONaJo" alt=""><figcaption></figcaption></figure>

For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth or attached to the top of Nybble's head), of course, you can also use your creativity according to actual needs.

## Software setup

You can use the [Arduino IDE](https://www.arduino.cc/en/software) to upload the demo code (test\_Touch\_Reflection\_PIR.ino) or compile and upload your own code.

<figure><img src="/files/yXcJAPMU66ggYfyGEYYq" alt=""><figcaption></figcaption></figure>

This demo sketch (test\_Touch\_Reflection\_PIR.ino) implements real-time printing of sensor detection results in the [serial monitor](https://docs.petoi.com/arduino-ide/serial-monitor) - when anyone moves within its detection range, print 1; otherwise, print 0.

<figure><img src="/files/LJCOqd0lvhIbye9DyTei" alt=""><figcaption></figcaption></figure>

### The demo code

The demo code is in the OpenCat code repository on GitHub (specific path: OpenCat/ModuleTests/test\_Touch\_Reflection\_PIR). You can visit our GitHub code repository <https://github.com/PetoiCamp/OpenCat> to download the complete code, as shown in the following figure:

<figure><img src="/files/2SiGuogG9ojUp2nlJTN3" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.petoi.com/thai/extensible-modules/pir-motion-sensor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
