stepper motor stop command

Hello ,
I'm using the following code to run a stepper motor. The motor works fine. However, I want to modify the code, so that the motor would rotate a specific distance and stop, rather than rotate continuously in a loop. I really do not have much idea about arduino coding. So could someone please help me..Thanks in advance!!

Here's the code I'm using

int Distance = 0; 

void setup() {                

  pinMode(8, OUTPUT);     

  pinMode(9, OUTPUT);

  digitalWrite(8, LOW);

  digitalWrite(9, LOW);

}


void loop() {

  digitalWrite(9, HIGH);

  delayMicroseconds(200);          

  digitalWrite(9, LOW); 

  delayMicroseconds(200);

  Distance = Distance + 1; 

    if (Distance == 3600)

  {

        if (digitalRead(8 ) == LOW)

    {

      digitalWrite(8, HIGH);

    }

    else

    {

      digitalWrite(8, LOW);

    }

       Distance = 0;

        delay(500);

  }

}

Can you read the guidelines and edit your post to use code-tags - then you won't get parts of
it scrambled into emoticons.

You want to move once and stop?

const int StepPin = 9;
const int DirPin = 8;

int Distance = 0; 

void setup() {                
  pinMode(DirPin, OUTPUT);     
  pinMode(StepPin, OUTPUT);
  digitalWrite(DirPin, LOW);
  digitalWrite(StepPin, LOW);
}

void loop() {
  // Take one step
  digitalWrite(StepPin, HIGH);
  delayMicroseconds(200);          
  digitalWrite(StepPin, LOW); 
  delayMicroseconds(200);
  Distance = Distance + 1; 

  // Have we reached the destination?
  if (Distance == 3600) {
    // Prevent the sketch from doing anything further
    while (true) /* Do nothing*/ ;
  }
}

Hi,
Yes. I want to command it to make it rotate a specific number of steps and stop.
Thank you John!! :smiley: