running pump using a pressure switch


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??

Being a newbie myself, I had a very good and steep learning curve, on how to write my first simple programs (sketches), using the Learning part of this Site.

You MUST have the patience and take the time, to learn some basics, to understand what progarmming is about on the Arduino board.
If not - you will just stare at what code you are given, and wont have a clue, if a problem arises.
It will take you a couple of days, but pretty soon you will be discussing programmig questions with the rest of the gang here - I promise you - as I've been through it myself :slight_smile:

Start here !