Problem with Code to Open Solenoids

It remained to explain what is connected to this pin and the purpose of this device.

I suggest you post a schematic (wiring0 of your project, even if done freehand