PIR motion sensor + counter / How to reset counter on X seconds.

Hi Guys,

I'm new at this forum. I'm building a motion sensor for my front door. Got a Partical Photon with an Grove Shield and a Grove PIR Motion sensor. I'm checking the highs for movement, but the wifi chip on the Partical interfere every 2/3 minutes (1 high). Googled a lot about this, but couldn't find a solution (other than board with ethernet or a different sensor). So I thought I could count the highs. I've there are like 5 highs in 30 sec then there is movement. I builded a counter out of a button counter example on the internet, but I don't know how to reset the counts after like 30 seconds or something. Could anybody help me with that :slight_smile:

const int buttonPin = 2; // the pin that the pushbutton is attached to
const int ledPin = 7; // the pin that the LED is attached to

// 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() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize the LED as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communication:

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

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button went from off to on:
Particle.publish("movement detected");
Particle.publish("number of button pushes: ");
} else {
// if the current state is LOW then the button went from on to off:
// Delay a little bit to avoid bouncing
// save the current state as the last state, for next time through the loop
lastButtonState = buttonState;

// turns on the LED every four button pushes by checking the modulo of the
// button push counter. the modulo function gives you the remainder of the
// division of two numbers:
if (buttonPushCounter % 3 == 0) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);


Post a link to that Partical Photon board as it's no standard Arduino board. If a Particle Photon is meant, that board doesn't even use the Arduino IDE according to linked page so we don't know if the above code can work.