dumping effect on pressure sensor

Hello all!
i am looking for a dumping code that will create a dumping effect on the sensor input.
the sensor is connected on the feed line of a pulse water pump,
the pulses created by the pump making in the first few seconds a big jumps in the pressure, this transmit mixed data of "1" and "0" to the arduino which cause it to run the turn off function.

i am looking for a code that will prevent this and will be more forgiving if one or two "0"s are sent into the arduino input.


I'm thinking "dumping" means "damping"?

First off, when you say "data of "1" and "0" to the arduino " do you mean a sequence of digital highs and lows, or do you mean numbers 1 and 0 on the Serial interface.

If the latter, you can compare each incoming value with the previous, keep a counter of how many consecutive lows you had, and only do the "off" function if you had say 5 in a row.

If the former, random highs and lows on a pin, it might be better to go by time: if the pin has been low for say 3 seconds or whatever, then that counts as a real low, so do the "off" function. The state change detection example shows how to look for the pin going low. When it does go low (note I say go low, not is low), start a millis() based timer. If it goes high before the 3 or whatever seconds, cancel and wait for a new low at which point start the timer again.

Edit: that last is really just debouncing.