step Motor

hi all ,

 

i want to know if i am doing correct configuration?

i have these driver and the step motor below.

driver

a) http://i1265.photobucket.com/albums/jj519/soni991/IMG_6732.jpg

b) http://i1265.photobucket.com/albums/jj519/soni991/IMG_6731.jpg

motor:a) http://i1265.photobucket.com/albums/jj519/soni991/IMG_6733.jpg

i am connecting thsoe 4 pin out from driver to the mega 2560 from pin 8-11

and the code as below.

 

int motorPins[] = {8, 9, 10, 11};
int count = 0;
int count2 = 0;
int delayTime = 500;
int val = 0;

void setup() {
for (count = 0; count < 4; count++) {
pinMode(motorPins[count], OUTPUT);
}
}

void moveForward() {
if ((count2 == 0) || (count2 == 1)) {
count2 = 16;
}
count2>>=1;
for (count = 3; count >= 0; count–) {
digitalWrite(motorPins[count], count2>>count&0x01);
}
delay(delayTime);
}

void moveBackward() {
if ((count2 == 0) || (count2 == 1)) {
count2 = 16;
}
count2>>=1;
for (count = 3; count >= 0; count–) {
digitalWrite(motorPins[3 - count], count2>>count&0x01);
}
delay(delayTime);
}

void loop() {
val = analogRead(0);
if (val > 540) {
// move faster the higher the value from the potentiometer
delayTime = 2048 - 1024 * val / 512 + 1;
moveForward();
} else if (val < 480) {
// move faster the lower the value from the potentiometer
delayTime = 1024 * val / 512 + 1;
moveBackward();
} else {
delayTime = 1024;
}
}

 

What would help would be

What would help would be links to specifications for your motor drivers and motors, rather than just pictures of them.

In the meantime, here is the very best reference I have found on stepper motors. You will learn a lot by reading it. 

http://homepage.cs.uiowa.edu/~jones/step/

I know this one.

I would use the step example that is included in the Arduino software. Also, for some reason, you have to swap two pins to make it work. Use this:  

Stepper(200, 8, 10, 9, 11);  //notice 9/10 have been swapped.