Bipolar Stepper motor with Big easy driver

Hey guys, a newby here,
I am new to this forum and posting my first query regarding the stepper motor and big easy driver.
I want to rotate the stepper motor to a particular steps say 1000(CW&CCW) then with a delay of 2 seconds then to different number of steps say 1600(CW&CCW) and then back to 1000 and so on in a loop.
I am new to the programming so I took some lessons from youtube and connected my BED's DIR and STEP pins to 8 and 9 on arduino and powered the 24v to the motor.
This program works good for only one defined steps. Tried some experimenting with creating another loop but the motor won't run. If anyone can help me with the code, i'd be obliged

int Distance = 0;

void setup() {
 pinMode (8, OUTPUT);
 pinMode (9, OUTPUT);
 digitalWrite (8, LOW);
 digitalWrite (9, LOW);
}

void loop () {
 digitalWrite (9, HIGH);
 delayMicroseconds (350); //time to reach to that position
 digitalWrite (9, LOW);
 delayMicroseconds (350);

 Distance = Distance + 1; //records this step

//check to see if we are end of our move

 if (Distance == 1000) { //you can change the number of steps to adjust the appropriate angle, here it is approx 60deg
   if (digitalRead(8) == LOW) {
     digitalWrite(8, HIGH);
   }
   else {
     digitalWrite(8, LOW);
   }
   Distance = 0; //reset the distance
   delay(1000); //time delay between the opposite direction
 }

}

have a look at my thread 'stopping and starting with accelstepper' just below. i've been getting some very useful advice on doing something fairly similar - ie. getting a stepper to stop and go on a loop. the big change you need to make is using millis() instead of delay()

Hi,
Welcome to the forums.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

blamski:
have a look at my thread ‘stopping and starting with accelstepper’ just below.

“just below” does not work. You need to provide a link

@ajayr14, Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

…R
Stepper Motor Basics
Simple Stepper Code