Electronic – arduino – How to count these spikes

analogarduinosignal processingwaveform

This signal is from an instrumentation amplifier,
read from Arduino MEGA2560 ADC,
loop delay 10ms (rate 100Hz)

I need to count high spikes only, (in below figure, 6 high spikes can be observed)

Edited
its and ECG signal and signal was sampled at a rate of 100Hz

enter image description here

Best Answer

It can be done by using some high pass filter to remove DC bias, then you differentiate the signal to detect high dv/dt. At each high dv/dt you set a flip-flop. If the FF is set you compare the amplitude threshold and you clear the FF when dv/dt becomes negative.