PIR ARDUINO

in pratica il sensore e' come se fosse un pulsante... quindi si rileva il cambio di stato

usa questo sketch per provarlo, non c'e' bisogno che colleghi la resistenza, e' stato abilitato il Pullup.
Colleghi un capo del connettore ALARM al pin 2 di arduino e l'altro al GND

quando il sensore rivela un movimento lampeggerà il led presente sul pin 13 di Arduino

const int  buttonPin = 2;    // the pin dove e' collegato il sensore
const int led = 13;       // il pin del LED

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {

  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}


void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  if (buttonState != lastButtonState) {

    if (buttonState == HIGH) {
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter);
      lampeggio();
    } 
    else {
      Serial.println("off"); 
    }
  }

  lastButtonState = buttonState;

}
void lampeggio() {
  for (int i=0; i <= 5 ; i++){
    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(200);               // wait for a second
    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
    delay(200);  
  }  
}