TolpuddleSartre:
Have you done the arithmetic using unsigned longs?Provided you don't try to measure times greater than then 49 days, the rollover is not a problem, and even if you do want longer times, it is very simply handled.
I am not sure I understand: suppose the last milli is 9999, and the valve opens at 9990, and startTime = millis(); which will then be 9990. A few moments later millis() reverts back to 0 counting upwards.
If I set an alarm that depens on the time difference between millis() and startTime then I will never be able to set the alarm? No?