PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Examples
Devices
Sensor
PIR Motion
PIR Rev B.c
1
/*
2
PIR Rev B.c
3
4
http://learn.parallax.com/propeller-c-simple-devices/pir-motion-sensor
5
6
Connect:
7
OUT to P5
8
VCC to 3.3V
9
GND to GND
10
11
The PIR sensors OUT pin sends a high signal for several seconds if motion is detected.
12
This output is copied to a variable named state with the statement: state = input(5).
13
The state variable will store 1 if motion has been detected recently, or 0 if it has
14
not. Detected output (state = 1) takes several seconds to clear after motion event
15
is over.
16
*/
17
18
#include "simpletools.h"
// Include simpletools library
19
20
int
main
()
// Main function
21
{
22
while
(1)
// Main loop
23
{
24
int
state = input(5);
// Check sensor (1) motion, (0) no motion
25
print(
"%c state = %d%c\n"
,
// Display sensor
26
HOME, state, CLREOL);
27
pause(200);
// Pause 1/5 second before repeat
28
}
29
}
30
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12