Indipendently control Relays

I think you need to first look at the control of one valve the way you want it to and then multiply by the number of valves.

millis will be running, so you can use that to time your intervals.

if (valve == ON && before - millis() > interval_on) {
    valve = OFF; 
    before = millis(); }

if (valve == OFF && before - millis() > interval_off) {
    valve = ON; 
    before = millis(); }

This can be made cleaner by arranging the data in an array for example:

struct valves[7] {
int pin_number;
int time_on;
int time_off;
}

for (int i = 0 ; i< 7; i++) {
   if (valve[i] == ON && before[i] - millis() > time_on[i]) {
      valve[i] = OFF; 
      before[i] = millis(); }

   if (valve[i] == OFF && before[i] - millis() > time_off[i]) {
      valve[i] = ON; 
      before[i] = millis(); }
}

Something like this, the code is full of errors, but could be a possibility. :slight_smile: