74HC595N control solenoid - arduino startup problem

Hi, and welcome to the forum.

Maybe the error is in your code (which you didn't post), or in your hardware (that we can't see).
Read the "how to post" sticky that's on top of every main page.
Leo..