AccelStepper Library help. (Begginer)

I want to turn my step motor (28BYJ-48) 90 degrees and then back to 0, just once not in a loop. I have very little to none experience in C programming but I’d appreciate any help. This is what I have so far:

#include <AccelStepper.h>

// Define a stepper and the pins it will use


// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
// Notice, I'm passing them as Blue, Yellow, Pink, Orange (coil ends order) not
// Blue, Pink, Yellow, Orange (firing order). 
AccelStepper stepper1(4,2,4,3,5);       //Set stepper motor for HALF-Stepping(4)

void setup()
{  
  stepper1.setSpeed(100.0);         
  //Tell it how fast to accelerate
  stepper1.setAcceleration(200.0); 
  //Set a maximum speed it should exceed 
  stepper1.setMaxSpeed(4000.0);      
  //Tell it to move to the target position
  stepper1.moveTo(200);        //moves to particular position. note that max 4096 steps for half stepping, 2049 for full stepping
  
if(stepper1.distanceToGo() == 0)      //when it reached its position tell it to go back to starting position
  {
    stepper1.moveTo(0);
  }

}
 
void loop()
{  
   stepper1.runSpeed();
}

You need to have an instuction (such as moveTo() ) that tells the motor to move the required number of steps for 90 degrees and when that move is complete (you can use the distanceToGo() function to check) you need to have another moveTo() to send it back to 0.

Note that moveTo() does not cause anything to happen - it just sets the destination. You need repeated calls to run() to make the moves happen. Calling run() too often is no problem - it is actually good practice.

You might also use the function runToPosition() which blocks the Arduino until the move is complete. This is OK for a simple program but would probably cause problems in a more complex application that needs fast response times.

...R

In addition to what @Robin2 said:

I want to turn my step motor (28BYJ-48) 90 degrees and then back to 0, just once not in a loop

Do you really want to have this feature ONCE, when the Arduino boots up, or when you trigger it - say, with a button or another sensor?