Nema 17 problem

I am recently working on a NEMA 17 bipolar stepper motor and I am using the TB6560 driver. The problem is that the motor does not rotate only one complete revolution for 200 steps. Instead, it is rotating clockwise as long as it is powered by the 12V supply.

Here is my code:

int T = 200; // Motor speed

//stepper motors
#define MOTORDIR1 41
#define MOTORSTEP1 35

void setup () {

pinMode(MOTORDIR1, OUTPUT);
pinMode(MOTORSTEP1, OUTPUT);
digitalWrite(MOTORSTEP1, LOW);
}

void loop() {

digitalWrite(MOTORDIR1, LOW); // HIGH Enables the motor to move in a particular direction CW
for (int x = 0; x < 1000 ; x++) {
digitalWrite(MOTORSTEP1, HIGH);
delayMicroseconds(T);
digitalWrite(MOTORSTEP1, LOW);
delayMicroseconds(T);
}
}

Can anyone help me to correct the mistake?

TOPIC SPLIT
DO NOT HIJACK / NECRO POST !

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

You have posted a new question in an old Thread and your question is about a different type of stepper motor so I have suggested to the Moderator to move you to your own Thread.

nurkhan:
The problem is that the motor does not rotate only one complete revolution for 200 steps. Instead, it is rotating clockwise as long as it is powered by the 12V supply.

I see two problems.

First, your code is asking the motor to do 1000 steps rather than 200.
Second, because the code is within loop() as soon as the 1000 steps are complete it starts another 1000.

If you want it to stop moving after N steps then you need a variable to keep track of whether it has completed the move or not. For example suppose you create a global variable

bool motorMoveDone;

then in setup() you can set it to false to start things off

motorMoveDone = false;

and your code to do the steps can then check that value

if (motorMoveDone == false) {
   for (int x = 0; x < 200 ; x++) {
     digitalWrite(MOTORSTEP1, HIGH);
     delayMicroseconds(T);
     digitalWrite(MOTORSTEP1, LOW);
     delayMicros
  }
  motorMoveDone = true;
}

...R

It is customary on this forum (and very helpful to others) to use code tags.

[code]your code here[/code]

Reason for edit:
There was an error when the topic was split and I did not know Robin2 replied already. His reply is more in depth (and more accurate). I wouldn't have replied at all if I had known about it.

Check out the AccelStepper library and its examples, saves a lot of grief for simple stepper control.