Help with a pulse detection func

I got the sensor running but then it just blinks in the pase of the pulse..

So, you need to count the number of pulses in some period of time, and calculate beats per minute. Then, do something when beats per minute is above your threshold. Or below it.