interrupt starts at different times depending on upload time of program

freda42:
I have moved the delay to another function that the interrupt routine calls, even though it doesn't really make a difference.

That is not the correct idea.

In your code the function loop() will repeat frequently.

Your ISR should set a global variable to say that the interrupt has happened.

The code in loop() should check that variable and if it is set, do whatever and unset the variable.

...R