marioacosta556:
I need to move the stepper X number of steps when the button is pressed and then stop to wait the next button press.
What happens when you try the code you posted?
You seem to have the motor working with
stepper.setMaxSpeed(100);
stepper.setAcceleration(100);
so why are you changing to ridiculous numbers with these lines
stepper.setMaxSpeed(500000);
stepper.setAcceleration(5000);
stepper.setSpeed(2800);
...R