Starting pump using a pressure sensor


i have a pressure sensor which gives me an output of 0-5v. im using this voltage as an analog input on my arduino board. the output should drive a relay and it will drive a pump.

what i want to do is when the sensor will give an input of 1-4v, this should activate my pump. if input is higher than 4v, pump stop. then the pump start again when the input voltage decreases to 1v then increase again to 4v for it to stop.

my problem here is that i don't know what statement to write so that the pump starts at 1v as input and it continues till the input voltage reaches 4v then it stop. then it should wait for the voltage to decrease to 1v for it to start again.

someone can help me to write some statement for such operation??

Look at if/else in Arduino's reference section.
A/D converts 0-5volt to 0-1023, so you have to calculate corresponding numbers first.
4volt = 4/5 x 1023 = ~ 818

You might want to program a "dead" zone.
e.g. pump on when 0-3.8volt and pump off above 4.2volt.
e.g with two if statements.