Peterold
New Member
I'm switching between 4 different sets of solenoid valves. They fill a tank, the rising water flips a float switch, it shuts off/drains the current tank, and begins filling the next. If 2 valves flip on at the same time, all of the valves shut off because the current load is too high for the arduino. In any normal circumstances there will never be 2 sets of valves on at a time, but I want to have a reset in case 2 switches flip and the system shuts off.
I can read every time a switch flips, so my idea was to have the arduino count to some time (say 30 min) and if no switches had flipped within that amount of time it would reset the process. I thought this sounded easy, but I can't seem to make it work. I'm not that familiar with arduino, and I've mostly been using if loops. Is there a function designed for this application?
Here's the code for switching solenoid valves:
if (voltage0 > 2.5) //Tank 1: If voltage is high (tank is full), arduino waits 5 sec for siphon to start. Then opens Tank 2 valve and closes Tank 1 valve.
{
delay(5000);
digitalWrite(valvePin0, LOW);
delay(3000);
digitalWrite(valvePin1, HIGH);
}
if (voltage1 > 2.5) //Tank 2: If voltage is high (tank is full), arduino waits 5 sec for siphon to start. Then opens Tank 3 valve and closes Tank 2 valve.
{
delay(5000);
digitalWrite(valvePin1, LOW);
delay(3000);
digitalWrite(valvePin2, HIGH);
}
....
I can read every time a switch flips, so my idea was to have the arduino count to some time (say 30 min) and if no switches had flipped within that amount of time it would reset the process. I thought this sounded easy, but I can't seem to make it work. I'm not that familiar with arduino, and I've mostly been using if loops. Is there a function designed for this application?
Here's the code for switching solenoid valves:
if (voltage0 > 2.5) //Tank 1: If voltage is high (tank is full), arduino waits 5 sec for siphon to start. Then opens Tank 2 valve and closes Tank 1 valve.
{
delay(5000);
digitalWrite(valvePin0, LOW);
delay(3000);
digitalWrite(valvePin1, HIGH);
}
if (voltage1 > 2.5) //Tank 2: If voltage is high (tank is full), arduino waits 5 sec for siphon to start. Then opens Tank 3 valve and closes Tank 2 valve.
{
delay(5000);
digitalWrite(valvePin1, LOW);
delay(3000);
digitalWrite(valvePin2, HIGH);
}
....