I have a function for manually jogging a stepper motor using the AccelStepper library. At the beginning of the function I would like the motor in question to be selected until told to stop.
Here is what I imagine it would look like:
AccelStepper X_Axis(AccelStepper::DRIVER, 3, 2);
AccelStepper Y_Axis(AccelStepper::DRIVER, 5, 4);
AccelStepper Z_Axis(AccelStepper::DRIVER, 7, 6);
void ManualJog(int Dir, int Spd, int axis)
{
int i;
if (Dir == 0){i = 1;}else{i =- 1;}
setSpeed(i * Spd);
switch(axis)
{
case 1:
axis = X_Axis;
break;
case 2:
axis = Y_Axis;
case 3:
axis = Z_Axis
}
while (!Serial.available()){
axis.runSpeed();
}
}
The axis variable should map to whichever axis is called and so control the desired stepper.
How can I achieve this?
Note: I submitted this to StackOverflow with no response. Any help would be appreciated