PIR Motion Sensor
This documentation includes installation guidelines and sample code for your hardware.
Windows 10 IoT Core Library
PIRSensor library is responsible for reading motion state from the PIR sensor.
To use the library, add the following using statement to the top of your C# code.
Then, create an instance of the PIRSensor class.
Now you're ready to access the library by calling the pirSensor instance.
Initialization
PIRSensor
Initiates the AM312 PIR sensor to detect human motion.
Parameters
None
Interrupts
PIR Motion Detect State Changed
Notifies on PIR motion detect state change.
Event Args
Bool Motion: True if motion is detected. False if not.
Disposal
To clean up the resources used by the class, call the Dispose() method it when the application is closing.
This method cleans the resources used by the class.
Samples
You can copy the example code from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Windows10IoTCore address. There is one example of this library.
Motion Detect Sample App
This application demonstrates reading motion state from the PIR sensor.
To run the example:
Open the sample project you downloaded.
Make sure "ARM" is selected from the solution platforms selection.
Deploy the sample to the Raspberry Pi using the "F5" key.
Sample Code
Result
When you run the sample, it prints the motion state changes to the Visual Studio Output / Immediate Window.
To stop the application, use the "Stop" button on the Visual Studio.
Last updated