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.
void setup() { void moveForward() { void moveBackward() { void loop() {int motorPins[] = {8, 9, 10, 11};
int count = 0;
int count2 = 0;
int delayTime = 500;
int val = 0;
for (count = 0; count < 4; count++) {
pinMode(motorPins[count], OUTPUT);
}
}
if ((count2 == 0) || (count2 == 1)) {
count2 = 16;
}
count2>>=1;
for (count = 3; count >= 0; count–) {
digitalWrite(motorPins[count], count2>>count&0x01);
}
delay(delayTime);
}
if ((count2 == 0) || (count2 == 1)) {
count2 = 16;
}
count2>>=1;
for (count = 3; count >= 0; count–) {
digitalWrite(motorPins[3 - count], count2>>count&0x01);
}
delay(delayTime);
}
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;
}
}