Hi everyone!

So, I should create a function that handles the delay of the solenoid valve?

That would depend on when you want to call it, and what it does.

If this is correct, does this have any other effect other than "cleaning" up the code?

Maybe. Maybe not. Depends on the function. Sometimes, moving code to a function makes the code harder to follow, so creating a function is not always desirable. Usually, yes. Always, no.