Reverse Osmosis controller

I'm having a little trouble

Everything works and pump system will shut down as its supposed to but there is a delay from when the pressure switch (pressure) opens and shuts the pump down. is there any way to make this instant?

What I have noticed with the pressure switch is that it chatters a bit (opens and closes rapidly as the pressure drops in the pipe. there is nothing I can do about this. so id like to find a way to shut power off to relays as soon as the switch opens and voltage is dropped to LOW on the pressure pin.

I tried to make the Arduino reset if vltage drops on pressure pin by digitalwrite 27,LOW I got no errors in the code so I left it but the Arduino dosnt seem to reset

Im using an

UNO R3 NO pressure switch 2 ssr relays to switch 24VAC to activate 220VAC Motor Contactors push button

is there another way of doing it

/* ------REVERSE OSMOSIS CONTROL -----------------
1. momentary button is pushed to energize low pressure 
 relay coil 
2. when pressure switch detects that proper pressure 
 is reached the switch will close, sending voltage to arduino.
3. when voltage is detected from pressure switch the high pressure 
 relay waits 5 seconds and then energizes high pressure relay
4. if at any moment the pressure switch becomes normally open the
 system shuts down waits 30seconds and resets the arduino and 
    awaits a button push to start system all over again
const int lowbutton=A1; //Push button to start low pressure feed pump
const int lowRelay=12;  //Relay that sends 220 VAC to pump
const int pressure=A0;  // Pressure switch at rest is N/0 when pressure its N/C
const int highRelay=11; //Relay that sends 220VAC to High Pressure pum

void setup()
digitalWrite(27, HIGH); //make RESET pin #27 HIGH to keep it from resetting
pinMode(lowbutton,INPUT); //Start button  starts low pressure pump 
pinMode(lowRelay,OUTPUT);//relay for low pressure pump
pinMode(pressure,INPUT);//pressure switch
pinMode(highRelay,OUTPUT);// high pressure pump relay
void loop()
 (digitalRead(lowbutton)==HIGH)//when button pushed, if it reads 5v
   digitalWrite(lowRelay,HIGH); //turn on low pressure pump
   delay(2000);// delay 2 seconds to let pressure build up
(digitalRead(pressure)==HIGH)//if pressure switch senses pressure
    delay(3000);//delay 3 seconds 
    digitalWrite(highRelay,HIGH);//5v to high pressure relay
    digitalWrite(lowRelay,HIGH);//5v to low pressure relay
  (digitalRead(pressure)==LOW)// if pressure switch opens
  digitalWrite(highRelay,LOW);//turn off high pressure relay
  digitalWrite(lowRelay,LOW);//turn off low pressure relay
  delay(1000);//wait 1 second

Your problem is know as "water hammer". Water is not compressible and the shock wave of turning the water off very rapidly causes the impulse wave to travel back and forth on the pipes.

If you Google water hammer, you will see how to add a small air chamber to absorb the shock wave. No more than a T, and elbow and a capped nipple positioned vertically so it has air in the nipple.


digitalWrite(27, HIGH); //make RESET pin #27 HIGH to keep it from resetting

Highest pin # on UNO is 19, aka A5.
Do you have pulldown resistors on the input pins so they don’t float HIGH when the switches are open?

outsider: ? Highest pin # on UNO is 19, aka A5. Do you have pulldown resistors on the input pins so they don't float HIGH when the switches are open?

Sorry couldn't get my reset pin to do a reset by calling it resetPin so I tried 27 and didn't come up any errors tried digitalWrite (resetPin, HIGH); did not work

I have pulldown 1k resistors on the input pins at first I did not and the switches chattered a lot on startup so I added them.

Don't understand why you want to reset Arduino if pressure sw opens.

It seems my delays in the loop are whats causing the delay in the switch shutting down the system fast enough. the 3 second delay from when the switch is closed . to when it turns on the high pressure pump. is there a way to ignore this delay once the pump is on and the loop is running?

Yes. Learn about State Machines. When you're in the "Running" state, don't delay.