I am using a PIR sensor to detect motion within my environment. When there is motion the PIR sensor sends a value of 1 to the console. As soon as it detects no motion it goes to 0 numerous times via a setInterval() every second. Now at that point in time I want to detect how long 0 has been 0 and then at 10 minutes do something. I was thinking of doing a new Date().getMinutes();
once at start of motion and then another one when motion stopped and comparing those two. Am I on the right track?
I ended up adding a var i = 0;
outside of the setInterval() and within the if (myDigitalValue === 0)
loop I kept i++
until it hit the amount of seconds I was looking for and when it equaled that I ran a method.