Trying to work with this Tom Igoe code on for stepper motors, im using a 4 lead bi-polar motor hooked upto pins 8,9,10,11 using an H-bridge.....but how do i know which 4 motor cables go to the H-bridge 4 outputs .......just work though the 24 permutations?
And have i adjusted th code ok for 4 pins
from:
#define motorPin1 8
#define motorPin2 9
#define ledPin 13
// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);
#include <Stepper.h>
#define motorSteps 100 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 8
#define motorPin2 9
#define motorPin3 10
#define motorPin4 11
#define ledPin 13
// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);
void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(60);
// Initialize the Serial port:
Serial.begin(9600);
// set up the LED pin:
pinMode(ledPin, OUTPUT);
// blink the LED:
blink(3);
}
void loop() {
// Step forward 100 steps:
Serial.println("Forward");
myStepper.step(100);
delay(500);
// Step backward 100 steps:
Serial.println("Backward");
myStepper.step(-100);
delay(500);
}
// Blink the reset LED:
void blink(int howManyTimes) {
int i;
for (i=0; i< howManyTimes; i++) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
}