Water pump control hysteresis
Implementing hysteresis turns out to be quite straight-forward:

float pressure = read_pressure();
if (pressure &lt; x)
    turn_relay_on();
else if (pressure &gt;= y)
    turn_relay_off();