Read rate of change of signal

Hi Kishore

Just wanted to check I understand what you are trying to do.

The HC-SR04 puts out an ultrasonic "ping" when it sees a pulse on its input Trig pin. It then measures how long it takes for an echo to come back. Then it outputs a pulse on its output Echo pin - the duration of this pulse is the same as the time between the ping and the echo.

So, I assume you are generating pings every 50ms (for example) and you want to measure the echo times for 10 of them and then find the maximum and minimum echo times?

In that case, I would suggest you use a library called NewPing to generate the pings and get the echo times. Then use code like Mark T suggested to get max and min.

Note that there is a lower limit on how frequently you can send "pings". You obviously need to allow enough time for a valid echo to come back and be processed before sending another ping. From memory, it is 30ms.

EDIT: Bad use of "frequently". To clarify, lower limit on the interval between one ping and the next.

Hope this helps

Ray