Measuring duration of voltage peak

Save the value of millis() when the signal becomes greater than the lower theshold and less than the upper threshold, then each time through loop() test whether the current value of millis() is equal to or greater than the required period. If so then act accordingly