Hello all,
New to Arduino and I have a question about a condition.
How do I make the code move on to the next line (on step #3) if either one condition is met.
Either time of two hours is up or top switch closes.
/*
dual float switches, 3 solinoids
the circuit:
lower float switch opens solenoid to turn RODI unit on
and opens solenoid 1 to flush RO membrane for 3 min. Then
solenoid 1 closes and solenoid 2 opens for 1 minute to divert TDS
water to waste. Then solenoid 2 closes and solenoid 3 opens to
make good water. [color=red]Water continues to run until time is up
or upper float switch is acitivated[/color].Once any one of this conditions
is met, solenoid 3 closes, solenoid 1 opens and runs for 4 mins
to flush membrane. Then all silenoids are closed.
*/
// constants won't change. They're used here to
// set pin numbers:
const int Float1T = 2; // the number of float switch top
const int Float2B = 3; // the number of float switch bottom
const int Solenoid1 = 7; // the number for main water solenoid
const int Solenoid2 = 6; //the number for RO drain solenoid
const int Solenoid3 = 5; // the number for DI solenoid
// variables will change:
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0; // variable for reading the pushbutton status
void setup() {
// initialize the Solenoid pin as an output:
pinMode(Solenoid1, OUTPUT);
pinMode(Solenoid2, OUTPUT);
pinMode(Solenoid3, OUTPUT);
// initialize the Float switch as an input:
pinMode(Float1T, INPUT_PULLUP);
pinMode(Float2B, INPUT_PULLUP);
}
void loop(){
// read the state of the float valves:
buttonState1 = digitalRead(Float1T);
buttonState2 = digitalRead(Float2B);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState1 == LOW && buttonState2 == LOW) {
digitalWrite(Solenoid1, HIGH);
digitalWrite(Solenoid2, LOW);
digitalWrite(Solenoid3, LOW);
delay(180000); // FLUSH FOR 3 MIN
digitalWrite(Solenoid1, LOW);
digitalWrite(Solenoid2, HIGH);
digitalWrite(Solenoid3, LOW);
delay(60000); // FLUSH FOR 1 MIN
digitalWrite(Solenoid1, LOW);
digitalWrite(Solenoid2, LOW);
digitalWrite(Solenoid3, HIGH);
delay(7200000); //SET 2 HOURS OR UNTIL TOP SWITCH CLOSES TO MAKE CLEAN WATER
digitalWrite(Solenoid1, HIGH);
digitalWrite(Solenoid2, LOW);
digitalWrite(Solenoid3, LOW); //
delay(240000); // FLUSH FOR 4 MINS
digitalWrite(Solenoid1, LOW); //
digitalWrite(Solenoid2, LOW); //
digitalWrite(Solenoid3, LOW); //
}
}
I got this from the internet by the way, I hope it is ok.
Thank you