http://www.dfrobot.com/wiki/index.php/PIR_Motion_Sensor_V1.0_SKU:SEN0171
The test circuit is shown as in figure.
Component
- Raspberry Pi 2 Model B
- PIR Motion Sensor (DFROBOT SEN0171)
In order to test, make a simple code which is pirTest.c
#include <stdio.h>
#include <wiringPi.h>
#define PIR 1
int main(void)
{
if(wiringPiSetup() == -1)
return 1;
pinMode(PIR, INPUT);
int input = 0;
for(;;)
{
if(digitalRead(PIR))
printf("Motion Detected!\n");
delay(100);
}
return 0;
}
Compile and run the program.
pi@raspberrypi ~$ gcc -o pirTest pirTest.c -lwiringPi
pi@raspberrypi ~$ sudo ./pirTest
0 개의 댓글:
댓글 쓰기