DPDT Toggle switch and Arduino timer

The Solenoids are 24v solenoids, they require that to work so there is no damage being done. Also, the 24v is going into COM4 on the relay, not the arduino.

I appreciate the input Jimmy but it's not the project guidance that I have an issue with. The circuit works, it is up and running.

As was my original query, the problem is the sketch code required to switch off the relay after 5 seconds when the switch has been pressed. I realise I have my logic wrong but can't seem to figure it out. The delay function is also ineffective.

Regards.