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

Remarks

The Parallax PIR detects motion by emitting a high signal when motion is detected. The signal returns to a low state when motion stops.

Purchasing

The parallax PIR sensor is available from Parallax Inc:

Examples

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

using System.Threading;
using Meadow;
using Meadow.Foundation.Sensors.Motion;

namespace ParallaxPIR_Sample
{
    public class Program
    {
        static IApp _app; 
        public static void Main()
        {
            _app = new App();
        }
    }

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

        public App ()
        {
            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.");
        }
    }
}
Example Circuit

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

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