This is the Sketch that I used to test it on the Arduino :
/// PIR_SR505_Test_1.ino ///
///
/// HC-SR505 - replace Center CAP 1nF with 100pF or 10pF
/// 1nF 10sec delay
/// 100pF 1sec delay
/// 10pF 0.1sec delay
///
#define PIRPIN 8 // This is the D8 pin that we are going to use
#define LEDPIN 13
unsigned long motionDelay = 5000; // Motion Delay Timer
//unsigned long motionDelay = 3000; // Motion Delay Timer
//unsigned long motionDelay = 1000; // Motion Delay Timer
//unsigned long motionDelay = 100; // Motion Delay Timer
boolean inMotion = false; // Motion sensor need to be read or not flag
int Cnt = 0;
void setup()
{
pinMode(PIRPIN, INPUT);
pinMode(LEDPIN,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if ( digitalRead(PIRPIN) == HIGH && ! inMotion )
{
Cnt ++ ;
Serial.print("Motion Detected ");
Serial.print(Cnt);
Serial.println("");
inMotion = true;
digitalWrite(LEDPIN,1);
}
else
if ( digitalRead(PIRPIN) == LOW )
{
if(inMotion == false)
Cnt = 0;
inMotion = false;
digitalWrite(LEDPIN,0);
}
else
{
;
}
}