public class MotionSensor extends SmoothedInputDevice
A Passive Infra-Red (PIR) motion sensor.
A typical PIR device has a small circuit board with three pins: VCC, OUT, and GND. VCC should be connected to the Pi's +5V pin, GND to one of the Pi's ground pins, and finally OUT to the GPIO specified as the value of the 'pin' parameter in the constructor.
activeHigh, device
listeners
pinNumber
Constructor and Description |
---|
MotionSensor(int pinNumber)
Defaults 'threshold' to 1, eventAge t0 20ms and eventDetectPeriod to 10ms.
|
MotionSensor(int pinNumber,
GpioPullUpDown pud,
int threshold,
int eventAge,
int eventDetectPeriod) |
MotionSensor(int pinNumber,
int threshold,
int eventAge,
int eventDetectPeriod) |
getEventAge, getEventDetectPeriod, getThreshold, setEventAge, setThreshold, valueChanged
disableListener, waitForActive, waitForActive, waitForInactive, waitForInactive, waitForValue
close, enableListener, getPullUpDown, getTrigger, getValue, isActive, isActiveHigh, whenActivated, whenDeactivated
addListener, removeAllListeners, removeListener
getPinNumber
public MotionSensor(int pinNumber) throws RuntimeIOException
Defaults 'threshold' to 1, eventAge t0 20ms and eventDetectPeriod to 10ms.
If your PIR sensor has a short fall time and is particularly "jittery" you may wish to set this to a higher value (e.g. 5) to mitigate this.
pinNumber
- The GPIO pin which the motion sensor is attached.RuntimeIOException
- If an I/O error occurred.public MotionSensor(int pinNumber, int threshold, int eventAge, int eventDetectPeriod) throws RuntimeIOException
pinNumber
- The GPIO pin which the motion sensor is attached.threshold
- The value above which the device will be considered "on".eventAge
- The time in milliseconds to keep active events in the queue.eventDetectPeriod
- How frequently to check for events.RuntimeIOException
- If an I/O error occurred.public MotionSensor(int pinNumber, GpioPullUpDown pud, int threshold, int eventAge, int eventDetectPeriod) throws RuntimeIOException
pinNumber
- The GPIO pin which the motion sensor is attached.pud
- Pull up/down configurationthreshold
- The value above which the device will be considered "on".eventAge
- The time in milliseconds to keep active events in the queue.eventDetectPeriod
- How frequently to check for events.RuntimeIOException
- If an I/O error occurred.Copyright © 2016 mattjlewis. All rights reserved.