See if this code is what you need. (Except I didn't bother with the system reset, I have no idea why you want to do that and suspect it's unnecessary.) The serial output below shows you can press the button again once the cycle finishes: it's a state machine that cycles through the states of Waiting, Sol1 only, Sol1 and Sol2, Sol1 only (again) and back to Waiting. The serial output confirms how long the solenoids are on.
This whole thing is delay()-less: led13 should pulse nicely the whole time ala blink without delay.
Waiting for button @ 188
Solenoid 1 on @ 1051
Solenoid 2 on @ 2051
Solenoid 2 off @ 5051, was on for 3000
Solenoid 1 off @ 17051, was on for 16000
Waiting for button @ 17052
Solenoid 1 on @ 26371
Solenoid 2 on @ 27371
Solenoid 2 off @ 30371, was on for 3000
Solenoid 1 off @ 42371, was on for 16000
Waiting for button @ 42372
Solenoid 1 on @ 72189
Solenoid 2 on @ 73189
Solenoid 2 off @ 76189, was on for 3000
Solenoid 1 off @ 88189, was on for 16000
// forum 639092
//has a proofOfLife pulse on 13 to prove there's no blocking
// press button, solenoid 1 on
// 1s later solenoid 2 starts thats time=0
// t+3 solenoid2 off
// t+15 solenoid1 off (so 16 total for this one)
// since button takes us out of the only state where we look at it, we don't need edge detect
enum {state_WAITING, state_S1_ONLY_A, state_S1_AND_S2, state_S1_ONLY_B } currentState = state_WAITING;
unsigned long previousPulseMillis;
int pulseInterval = 500;
bool pulseLedState = LOW;
byte pulseLedPin = 13;
bool newlyArrivedInThisState = true;
// this constant won't change:
const int buttonPin = 3; // the pin that the pushbutton is attached to
// the button must be wired from pin to ground, its pinmode is input_pullup
const int solenoid1 = 14;
const int solenoid2 = 16;
const int solenoid1staysOnFor = 15000; //actually on for this + delayBetweenStarts
const int solenoid2staysOnFor = 3000;
const int delayBetweenStarts = 1000;
unsigned long buttonBecamePressedAt; //this is solenoid1 start time
unsigned long solenoid2startedAt;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(solenoid1, OUTPUT);
pinMode(solenoid2, OUTPUT);
Serial.begin(9600);
Serial.println(".... 2 solenoids 1 button ....");
Serial.print("Compiler: ");
Serial.print(__VERSION__);
Serial.print(", Arduino IDE: ");
Serial.println(ARDUINO);
Serial.print("Created: ");
Serial.print(__TIME__);
Serial.print(", ");
Serial.println(__DATE__);
Serial.println(__FILE__);
Serial.println("");
Serial.print("Current state "); Serial.println(currentState);
Serial.println("Setup done...\n");
}//setup
void loop()
{
proofOfLife();
doStates();
}//loop
void proofOfLife()
{
if (millis() - previousPulseMillis >= pulseInterval)
{
pulseLedState = !pulseLedState;
digitalWrite(pulseLedPin, pulseLedState);
previousPulseMillis = millis();;
}
}//proof of life
//state_WAITING, state_S1_ONLY_A, state_S1_AND_S2, state_S1_ONLY_B
void doStates()
{
switch (currentState)
{
case state_WAITING:
if (newlyArrivedInThisState)
{
Serial.print("Waiting for button @ ");
Serial.println(millis());
newlyArrivedInThisState = false;
}
if (!digitalRead(buttonPin))
{
newlyArrivedInThisState = true;
currentState = state_S1_ONLY_A;
}
break;
case state_S1_ONLY_A:
if (newlyArrivedInThisState)
{
Serial.print("Solenoid 1 on @ ");
buttonBecamePressedAt = millis();
Serial.println(buttonBecamePressedAt);
newlyArrivedInThisState = false;
digitalWrite(solenoid1, HIGH);
}
if (millis() - buttonBecamePressedAt >= delayBetweenStarts)
{
newlyArrivedInThisState = true;
currentState = state_S1_AND_S2;
}
break;
case state_S1_AND_S2:
if (newlyArrivedInThisState)
{
Serial.print(" Solenoid 2 on @ ");
solenoid2startedAt = millis();
Serial.println(solenoid2startedAt);
newlyArrivedInThisState = false;
digitalWrite(solenoid2, HIGH);
}
if (millis() - solenoid2startedAt >= solenoid2staysOnFor)
{
newlyArrivedInThisState = true;
currentState = state_S1_ONLY_B;
}
break;
case state_S1_ONLY_B:
if (newlyArrivedInThisState)
{
Serial.print(" Solenoid 2 off @ ");
Serial.print(millis());
Serial.print(", was on for ");
Serial.println(millis()-solenoid2startedAt);
newlyArrivedInThisState = false;
digitalWrite(solenoid2, LOW);
}
if (millis() - solenoid2startedAt >= solenoid1staysOnFor)
{
Serial.print("Solenoid 1 off @ ");
Serial.print(millis());
Serial.print(", was on for ");
Serial.println(millis()-buttonBecamePressedAt);
Serial.println(" ");
digitalWrite(solenoid1, LOW); // oops left this out
newlyArrivedInThisState = true;
currentState = state_WAITING;
}
break;
}//switch
}//doStates