I'm working to replace some code from a stepper project so that I can include and use the accelStepper library. I have zero experience with using libraries (I'm a newb). Currently the code I am using manually steps a motor using code something like below:
void moveHand(int hand, int steps)
{
int i = 0;
for (i=0; i<steps); i++)
{
digitalWrite(stepPin[hand], LOW); // Start out with step pin low
delayMicroseconds(300); // Delay controls speed and Torque I originally had these at 100 that was too short
digitalWrite(stepPin[hand], HIGH); // Now switch it high
delayMicroseconds(300); // Delay controls speed and Torque you need at least a 500 delay
}
}
You can see that the value for stepPin is stored in an array and elsewhere in the program this is what determines which motor moves ("hand" is used because the project involves moving hands on a clock face). I'm wondering how to handle this using the accelStepper library. I'll have three steppers, Stepper1, Stepper2, and Stepper3. I'd like to do something like store the stepper names in an array, but I don't think that's possible. I've only used arrays that hold ints, and I'm not sure an array can hold a value like this. For example:
stepper[] = {stepper1, stepper2, stepper3}
stepper[hand].moveTo(24);
I hope this makes sense to someone. I'm unfortunately away on business right now and can't experiment with my arduino for a few days, but I'm hoping to get some of the coding done before I get home. Thanks for any ideas!