/* 25/10/2021 * pirv2 * changed to a millis() timed function * * * pins used * 12 * * */ const int pirPin = 12; int myMovement = 0; unsigned long pirTimer; int pirScanDelay = 100;//time in milliseconds until the next pir scan takes place //function is now controlled by a millis() timer void pirScan(){ if(millis() > pirTimer){ pirTimer = millis() + pirScanDelay; myMovement = digitalRead(pirPin); Serial.println(myMovement); } } void setup() { Serial.begin(9600); Serial.println("pirv2..."); pinMode(pirPin,INPUT); } void loop() { pirScan(); }