My friend and I are having a problem with our stepper motor (Wantai nr. 87578689) and/or driver (A4988).
When we turn on the arduino the stepper motor turns for about 3 seconds and then stops. It then functions normally. The script can't cause the problem because yesterday (before I went to sleep) it worked fine. I also didn't change something to the hardware.
My friend does have the same hardware at home and uses another script and he faces the same problem.
Which pins is it connected to? Can you draw a full schematic for us? (Don't use F**ing's breadboard view and don't just copy-paste someone else's schematic unless you have verified that your real circuit matches that schematic precisely.) Which Arduino?
Can you post a minimum sketch which exhibits the problem? Does the standard Blink example also run the motor for 3 seconds?
I've tested it with the blink sketch and when I uploaded the sketch the motor starts turning like first but it doesn't stop and sometimes changes direction. Is there an possibility that the step pin en direction pin are receiving signals from the environment when they are on LOW state?
PS: The motor starts turning when the sketch is not fully uploaded. It's the moment when the arduino shuts of and then receives the new sketch.
If your sketch has set those pins to outputs and is driving them LOW then there's a very low probability that it's picking up stray signals. You would need very long wires (hundreds of meters) or some unbelievably strong interference source.
Did you set the pins to output mode?
Did you use the serial programming pins (0 and 1) by mistake?
We need to see the whole sketch and a precise picture of the wiring.
If you can't provide those information we would need instead a crystal ball showing your hidden information
I suspect there are some wires connected to either 1,2 and/or 13.
And: the motor is enabled right from the beginning instead of enabling it in the setup() routine.