Skip to content
Guillaume VILLEREZ edited this page Feb 14, 2016 · 1 revision

Data sheet

https://learn.adafruit.com/downloads/pdf/pir-passive-infrared-proximity-motion-sensor.pdf

How does it work

(Using wiringPi)

Read data

The PIR sensor is the easiest to use, because it will set its GPIO pin to HIGH when anything is detected, and to LOW when nothing is detected :

    int readPir(int pin) {
        // Prepare to read the pin
        pinMode(pin, INPUT);

        // Read the pin
        uint8_t state = digitalRead(pin);

        if(state == HIGH)
            return 1;
        else
            return 0;
    }
Clone this wiki locally