Turning on pins for varying amounts of time

I have 8 pins connected to 8 solenoids and I need to turn them all on and after a brief delay off again at regular intervals. The problem is that each one of the pins needs to be for a different amount of time because of variables in the hardware. That is to say, that they will on turn on at the same time but will turn off one at time at different intervals

How can I do this with an arduino?

How can I do this with an arduino?

How would YOU do it? Note what time you turned the switches on. Periodically, see if it is time to turn them off.

The millis() function acts like a clock with only a (milli)second hand that takes 49+ days to sweep around.

greengiant83:
I have 8 pins connected to 8 solenoids and I need to turn them all on and after a brief delay off again at regular intervals. The problem is that each one of the pins needs to be for a different amount of time because of variables in the hardware. That is to say, that they will on turn on at the same time but will turn off one at time at different intervals

How can I do this with an arduino?

An approach that should work is to set variables with the millis() value that the solenoids should
turn off at. During the loop() cycle, periodically check these values and turn off at the right time:

long solenoid1stop, solenoid2stop, solenoid3stop...;

void solenoidsOn() {
  digitalWrite(solenoid1pin, HIGH);
  digitalWrite(solenoid2pin, HIGH);
[..etc..]
  solenoid1stop = millis() + [millis to stay on for];
  solenoid2stop = millis() + [millis to stay on for];
}

void loop () {
...
  if (solenoid1stop && millis() > solenoid1stop) {
    digitalWrite(solenoid1pin, LOW);
    solenoid1stop = 0;
  }
  if (solenoid2stop && millis() > solenoid2stop) {
    digitalWrite(solenoid2pin, LOW);
    solenoid2stop = 0;
  }
...
}

If this was on windows/linux i'd automatically think Threading. but apparently not supported from the Atmega...

is an emulation of what threads do, this is kind of what you're after.