Hello,
I am trying to auto make Ro water and since I have no experience with Arduino, the code seems a little hard.
So far I this is what I want to accomplish and what I have.
/*
dual float switch, 3 solenoids
the circuit:
Upper float switch LOW, nothing happens.
Lower float switch LOW, opens solenoid 1 and 2
to flush RO membrane for 3 min.
Then solenoid 1 closes and solenoid 2 stays open for 1 minute
to divert TDS water to waste.
Then solenoid 2 closes and solenoid 3 opens to
make good water. Water continues to run until both float switches
are LOW.
Then solenoid 3 closes, solenoid 1 and 2 open and run for 5 mins
to flush membrane. Then all silenoids are closed.
*/
// constants won't change. They're used here to
// set pin numbers:
const int UpperFloat = 2; // digital pin of upper float switch
const int LowerFloat = 3; // digital pin of lower float switch
const int Solenoid1 = 5; // digital pin of DI solenoid 1 main water solinoid
const int Solenoid2 = 6; // digital pin of RO drain solenoid 2
const int Solenoid3 = 5; // digital pin of clean water solenoid 3
// 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(UpperFloat, INPUT_PULLUP);
pinMode(LowerFloat, INPUT_PULLUP
);
}
void loop(){
// read the state of the float switches:
buttonState1 = digitalRead(UpperFloat);
buttonState2 = digitalRead(LowerFloat);
if (buttonState1 == LOW && buttonState2 == LOW) {
digitalWrite(Solenoid1, HIGH);
digitalWrite(Solenoid2, HIGH);
digitalWrite(Solenoid3, LOW);
delay(10000); // FLUSH FOR 3 MIN
digitalWrite(Solenoid1, LOW);
digitalWrite(Solenoid2, HIGH);
digitalWrite(Solenoid3, LOW);
delay(10000); // 1 minute to divert TDS water
HERE IS THE ISSUE, I WANT ONLY SOLENOID 3 TO STAY HIGH UNTIL BOTH FLOAT SWITCHES
ARE LOW, (not timed)THEN
digitalWrite(Solenoid1, HIGH);
digitalWrite(Solenoid2, HIGH);
digitalWrite(Solenoid3, LOW);
delay(10000); // WAIT FOR FIVE MINUTES FOR FINAL FLUSH
then all solenoids LOW
Any help will be appreciated.