Remarks

ParallaxPir
Status
Source code GitHub
NuGet package

The Parallax PIR detects motion via infrared. It emits a high signal over the data pin when motion is detected. The pin returns to a low state when motion stops.

Purchasing

The parallax PIR sensor is available from Parallax Inc:

The following application creates a ParallaxPIR object and attaches interrupt handlers to the OnMotionStart and OnMotionEnd events:

public class MeadowApp : App<F7Micro, MeadowApp>
{
    ParallaxPIR parallax;

    public MeadowApp()
    {
        parallax = new ParallaxPIR(Device.Pins.D13);

        parallax.OnMotionStart += ParallaxMotionStarted;
        parallax.OnMotionEnd += ParallaxMotionEnded;
    }

    void ParallaxMotionEnded(object sender)
    {
        Console.WriteLine("Motion stopped.");
    }

    void ParallaxMotionStarted(object sender)
    {
        Console.WriteLine("Motion detected.");
    }
}

Sample projects available on GitHub

Wiring Example

The Parallax PIR sensor requires only three connections, power, ground and motion detection signal:

Characteristic Locus
Inheritance System.Object > ParallaxPir
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Sensors.Motion
Assembly ParallaxPir.dll

Syntax

public class ParallaxPir

Constructors

View Source

ParallaxPir(IDigitalInputPort)

Create a new Parallax PIR object connected to a interrupt port.

Declaration
public ParallaxPir(IDigitalInputPort digitalInputPort)

Parameters

Type Name Description
IDigitalInputPort digitalInputPort
View Source

ParallaxPir(IIODevice, IPin, InterruptMode, ResistorMode, Int32, Int32)

Create a new Parallax PIR object connected to an input pin and IO Device.

Declaration
public ParallaxPir(IIODevice device, IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, int debounceDuration = 20, int glitchFilterCycleCount = 0)

Parameters

Type Name Description
IIODevice device
IPin pin
InterruptMode interruptMode
ResistorMode resistorMode
System.Int32 debounceDuration
System.Int32 glitchFilterCycleCount

Events

View Source

OnMotionEnd

Event raised when the PIR indicates that there is not longer any motion.

Declaration
public event ParallaxPir.MotionChange OnMotionEnd

Event Type

Type Description
ParallaxPir.MotionChange
View Source

OnMotionStart

Event raised when motion is detected.

Declaration
public event ParallaxPir.MotionChange OnMotionStart

Event Type

Type Description
ParallaxPir.MotionChange