Thank you Mike and Sandy for the comments. As I said, I am just starting out. I have two motors running basic code at the moment, but am really trying to sort out how to use AccelStepper in this interactive mode, and reading the forum posts so far I haven't seen too many examples where there is user interaction. The thread from the end of May (Knob control using the accelstepper library), that Mike added to the samples sort of helped. But the differences in using a one-time adjustment on a pot vs. holding a button (or joystick) down to jog for an extended time/distance is where I was having trouble seeing how to structure the code.The subtleties of where to call accelstepper.run/motor.run are among the things I am trying to understand, and Sandy's examples of two ways to call .run inside loop() give me some ideas to try.I think I was imagining jogging within a while loop, e.g.while (jogRightButton != 0){motor.move(10); //or whatever the appropriate distance is after testingmotor.run();}I assume that the motor would keep running if the user kept the button pressed, maybe with some chugging, depending on the distance value used. And I think because this is an interactive process, it is ok to use a blocking call, because I'll keep jogging until they let go of the button at the desired location.Real jogging on CNC machines usually takes input from an encoder, and/or a range multiplier. I was sort of hoping I could get a similar effect, where holding a button longer, accelerated the motor, to cover longer distances. After I get the basic loop working, perhaps some sense of duration of the button press can be used to increase the speed/distance moved.I'm not at home right now, but clearly need to test some code for speed and distances to see what is appropriate once I get back to my bench.Thanks again for the suggestions.--Jon
I'm sitting in the airport between flights and can hardly wait to get home to test some ideas in code with motors now!
It is so helpful to get your feedback and insiights, as you clearly have a firm grasp on how AccelStepper works (I love your polargraph!!). I would have probably written the loop and stared at it wondering why it was only taking one step! Duh. Thanks again.
I'm wondering, and will experiment with it soon to see, if the longer run in the while loop will jerk to a stop when the button is released? From what I've read of the behavior, it sounds like the beginning of the while loop will let AccelStepper ramp up, but then not have time to decel when the button is released. And in truth, I'm not really sure what the desired jogging behavior is. I am sure I will find the speeds and accel settings that will make sense with the jogging, which in this case is sort of a way to get user input, then adjust the settings for the actual running cycle.
I'll know more later...
--Jon