Increasing the speed of a stepper motor using the A4988 and

Does the stepper motor turn when you run the code you posted? If so, can you post the faster-step code that did not work?

What do you have the A4988’s current limit set to? Also, I notice that your motor can be used as a unipolar or bipolar stepper; how do you have it connected to the A4988?

Generally speaking, you probably are not going to get more than a few hundred RPM from your stepper motor, but you should be able to do better than 120 RPM. There are a few main ways to increase your maximum step speed:

  1. Use a higher voltage. This lets the current ramp up faster every time you step and allows for a higher average current at high step rates.
  2. Set the current limit to the maximum allowed by your stepper motor. Unfortunately, you are using a stepper motor rated at 2 A per coil, but the driver you are using can only deliver around 1 A per coil without overheating. Adding a heat sink would let you get a little more current out of it, but I don’t expect you can get the full 2 A per coil out of it.
  3. Ramp the stepper speed up slowly. You can get the stepper motor to a much higher speed if you gradually increase your speed over time rather than trying to start at the maximum speed from rest.
  4. Decrease the external load on the stepper. The more torque your stepper motor needs to deliver, the lower it’s maximum step speed will be.

By the way, it looks like the datasheet for your motor has a lot of generally useful information on stepper motors on pages 29 and 30. Have you read that?

- Ben