While button is held, output another pin as high- up to a maximum time length

jremington:
Go through your logic very carefully.

As the code currently stands, you read out the time only when (digitalRead(ProxPin) == HIGH).

If you want all decisions to be based on the most current time, read it just after the start of the loop function.

The first decision is whether or not the proxpin is HIGH or not- if it is then its time to activate the relay and start the timer. If its not then the relay shall remain off.

I think this is where I'm confused. I'm expecting to need a sub-loop within the main loop, which will run when the proxpin is HIGH.

The sub-loop would turn on the relay for up to a certain time and then turn the relay off. The sub-loop would then have to stay put until the proxpin goes LOW, in which case the program continues in the main loop.

jremington:
Usually, people reset startMillis periodically. Otherwise this is a one shot program. In your case, it might make sense to reset startMillis either when the button is released, or pressed, depending on what you want to accomplish. Study the "blink without delay" program example to see what I mean.

This is a good point. I based my code off the "blink without delay" program, but cannot understand how to modify it to include the prox on/off and timer requirements.