Datasheet
4
3. Usage
3.1 With Arduino
The following sketch demonstrates a simple application of sensing motion. When someone moves
in its detecting range, it will output High through its SIG pin and the LED will light. Otherwise, it will
output LOW. Then you can use it to detect the motion of people.
/*******************************************************************************/
/*macro definitions of PIR motion sensor pin and LED pin*/
#define PIR_MOTION_SENSOR 2//Use pin 2 to receive the signal from the module
#define LED 4//the Grove - LED is connected to D4 of Arduino
void setup()
{
pinsInit();
}
void loop()
{
if(isPeopleDetected())//if it detects the moving people?
turnOnLED();
else
turnOffLED();
}
void pinsInit()
{
pinMode(PIR_MOTION_SENSOR, INPUT);
pinMode(LED,OUTPUT);
}