Thanks. How is it wired to the controller?
Schenatics of that, please.
At power up the controller I/O pins are either in treestate or set as inputs. Connect pulldown resistors to the controller-driver pins. Some 4.7 kOhm to 10 kOhm would do.
They are images with coloured wires.
Please draw a proper schematic, hand drawn image is fine.
Include Power Supplies, component labels and pin names, your controller.
Reverse engineer your project and draw a circuit diagram.
Aha. I'm an UNO guy so I can't tell for sure. Information like this, which controller is used should always be told in the first post.
My reply #5... At power up some built in code is executed. For instance, is a download in progress or not? If not (some second or two later) the execution of the code, setup and the loop takes place. During that initial startup some small things take place with the/some? I/O pins.
Nice You got it working. Keep the pulldowns on the desk.... See them as a spare try if things go strange again.
Maybe some Mega expert had stepped in earlier.....
Mysteries never help. It's frustrating to spend time and effort to create the original question.
The pulldown possibility works for several, maybe even many, controllers....