Mit PIR eine LED ansteuern - Arduino Uno R3

Bei den meisten PIR kann man per Jumper konfigurieren, ob sie einmalig eine detektierte Bewegung melden sollen, oder während der gesamten* Dauer.

Dann ist der Sketch so aufgebaut, dass er nur die Zustandsänderungen meldet. Also Detected und Ended.
Sonst bekommst Du ja alle paar Millisekunden eine Nachricht per Serieller Schnittstelle zugeschickt.

*Die gesamte Dauer ist natürlich dennoch endlich, da der PIR nur Zustandsveränderungen wahrnimmt. Steht jemand davor und bewegt sich nicht sonderlich viel, so meldet er Ended.

Das kann man aber etwas entprellen:

const int pirPin = 12;    //D6 the digital pin connected to the PIR sensor's output
const int ledPin = LED_BUILTIN;
//the time when the sensor outputs a low impulse
uint32_t lowIn;
//the amount of milliseconds the sensor has to be low 
//before we assume all motion has stopped
long unsigned int pause = 60000;
boolean lockLow = true;
boolean takeLowTime;

void PirCheck() {
  if(digitalRead(pirPin) == HIGH){
    digitalWrite(ledPin, LOW);
    if(lockLow){
       //makes sure we wait for a transition to LOW before any further output is made:
       lockLow = false;
       PirActive();
       delay(50);
     }         
     takeLowTime = true;   
  }else {
    digitalWrite(ledPin, HIGH);
    if(takeLowTime){
      lowIn = millis();          //save the time of the transition from high to LOW
      takeLowTime = false;       //make sure this is only done at the start of a LOW phase
    }
     //if the sensor is low for more than the given pause, 
     //we assume that no more motion is going to happen
     if(!lockLow && millis() - lowIn > pause){  
       //makes sure this block of code is only executed again after 
       //a new motion sequence has been detected
       lockLow = true;
       PirInactive();       
       delay(50);
     }
  }  
}

Nicht schön, sollte es aber machen...