Step motor control 90 degrees left and right using a4988?

Hi, I’m tung. I am using A4988 step motor driver now. I just want to know how to control step motor 90 degrees left right using a4988.
my code is here. How do I modify C code?

 #include <reg51.h>

sbit step = P2^0;
sbit dir= P2^1;
sbit reset = P2^2;
sbit sleep = P2^3;
sbit led = P1^0;

void delay(unsigned long i)
{ 
while(i--); 
}

void main(void)
{
//   unsigned int j;
   
   dir = 1;
   sleep = 1;
   step = 1;
   reset = 1;   
   led = 1;
   

  do{
      step = ~step;
      delay(100);
      led = ~led;
      }while(1);
}

Hello, Tung.

To control your stepper motor in terms of angle and not steps, you first need to calculate the angle per step for your stepper motor. For example, if your stepper motor has 200 steps per revolution, you would divide 360 degrees by 200, resulting in 1.8 degrees per step. Now that you know the step angle, you can figure out the number of steps your stepper motor needs to step to 90 degrees. For example, 90 degrees / 1.8 degrees / step = 50 steps. In your code, I suggest creating another function (e.g. stepDegree) which takes the desired angle as an argument and return the converted number of steps. Please note that the step angle will be different for each micro-stepping mode, so if you plan to change step modes, you should adjust your calculations accordingly.

- Amanda