Hi everyone! I've been trying to make a stepper Motor rotate for a certain amount of time IF I press a button once. For the momen I managed to make this coding, the motor does start rotating after I press the button, but it doesn't stop now. How should I fix it?
const int stepsPerRevolution = 512;
Stepper myStepper1(stepsPerRevolution, 10, 12, 11, 13);
int Switch = 2;
How to write Timers and Delays in Arduino deals with writing timers, but you could also use AccelStepper library and run to a given position which is probably what you actually want. You can reset the current position as 0 so you can just repeat running the same amount.