/*
  http://www.robotronix.co.il
   PIR sensor tester
   PIR : HIGH --> Motion detected 
   PIR : LOW  --> Motion ended 
*/

int ledPin = 12;                // choose the pin for the LED
int inputPin = 14;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input

  Serial.begin(9600);
}

void loop() {
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH)
   {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } 
  else 
    {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH) {
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}
uno:VIN
uno:GND.2
uno:D13
uno:D12
uno:D14
uno:D27
uno:D26
uno:D25
uno:D33
uno:D32
uno:D35
uno:D34
uno:VN
uno:VP
uno:EN
uno:3V3
uno:GND.1
uno:D15
uno:D2
uno:D4
uno:RX2
uno:TX2
uno:D5
uno:D18
uno:D19
uno:D21
uno:RX0
uno:TX0
uno:D22
uno:D23
pir1:VCC
pir1:OUT
pir1:GND
led1:A
led1:C
r1:1
r1:2