Accel Stepper and Servo at Same Time

this code is based on the “overshoot” example… it simply ramps the motor one way, stops and ramps the opposite way.

I would also like to have use of a servo via potentiometer at the same time the motor is stepping ( it is for a camera rig with servo for focusing).

what I get is a complete movement to the new position, then a servo move, then a motor move, rather than both at the same time.

what am I doing wrong?



#include <VarSpeedServo.h>
#include <AccelStepper.h>

AccelStepper stepper(1,12,13);
VarSpeedServo fServo;
int goPos=5000;
#define APOT A2

void setup()

int prevRead;
void loop()

int potRead = map(analogRead(APOT),0,1023,0,180);

while (stepper.currentPosition() !=goPos){;

// cause an overshoot as we whiz past 300

perhaps this should be under coding issues, but if clarification is needed: I am running the sparkfun easy stepper on pins 12 and 13. I thought the Accel stepper library was non-blocking, how can I maintain the accelerations and decelerations while focusing at the same time-- with the AF stepper library it was as simple as something like this in the main loop:


however, if I am not mistaken, accelstepper library will not implement accelerations without the run() or other such statements..(e.g. runSpeedToPosition())--

some are blocking most are not--- however, run() sure seems to block my loop... no doubt it is how I am implementing but I have tried to break it up into smaller chunks with no luck... looking for some ideas based on experience that I lack. Thanks in advance.