Counting pulses

Thanks folks.... perhaps I was wrong about interrupts. I have run out of external interrupts but I see one can use pin change interrupts with this Library: Arduino Playground - PinChangeInt. I figured that if I use the milli timer to give me a 5 second slot I could then enable (attach) the interrupt at the start of the 5 seconds, with each interrupt causing a ++ count, and dettach the interrupt at the end of the 5 second slot to stop counting.

Perhaps the concept is OK but my coding is poor so it is not working :frowning:

The pulses look like the attached image.

Thoughts on how to properly code the concept above would be great... here is what I have done:

void reportAnemometer() {
  
  currentTime = millis();
  loopTime=(currentTime+5000);
  if(currentTime <= loopTime)
  {attachInterrupt(PIN1, &windPulse, RISING);
}
  else
  {detachInterrupt(PIN1);
   loopTime=0;}
 
  WindSpeed = (wPulse/ 5) * 2.4; //2.4 K/h for one switch closure per second
  Serial.print("WindSpeed: ");
  Serial.println(WindSpeed);
  wPulse=0;
}

  void windPulse() {
  wPulse ++;
  Serial.println("Wind Pulse");
}

IMAGE004.jpg