Accelstepper itself mostly doesn't loop at all, I think that's what
puzzled me the most when I first started with it.
You tell it a target position using accelstepper.moveTo(), but that in
itself doesn't make it move. You've got to then call
accelstepper.run(), and if a step is due, then the motors will take
one step. Only one. Which is why .run() is usually in a loop, either
the main loop() method in your sketch, or one like
while (accelstepper.distanceToGo() != 0) {
accelstepper.run();
}
And that's how it can do various different speeds without blocking the
rest of your program - if it's a very slow speed, then only one out of
every thousand calls to .run() will result in the motors actually
moving. I think it's a brilliant piece of work.
There are a couple of methods that have a loop built-in,
runToNewPosition(), runSpeedToPosition() and runToPosition() all loop
internally, so they do block. Once you've called one of those, then
you've just got to wait until it returns before you can do anything.
With plain .run() you can be doing all kinds of other stuff in the
same loop as the run(). I use this library on my polargraphSD
machines (
polargraph.co.uk), and the movement loop also has a call to
some check for input routines, so it's busy checking if buttons have
been pressed, and updating the touchscreen at the same time as running
a couple of motors. When I do something like refresh the screen in
that loop, the motors pause, because the run() isn't being called
frequently enough, so if you want to have accurate, smooth speed, then
you need to be sure that the other things in your loop do not take
much time.
In your case, I think you've got to pause it to get the camera
steadied and to take the pic, you might even want a little pause after
the pic too, in case the motor takes off before the image has finished
being captured. But by inserting delays, or making calls to things
that take a long time to finish, you aren't really interrupting the
loop, you're just delaying the next call to run(). How frequently
.run() can be called controls the top speed of the motor. If you tell
it to go at 50,000 steps per second, but your arduino can't loop that
fast, then it isn't going to work :) With slow time lapse stuff,
you'll be fine.
Not sure if that's any clearer :)
sn