I've never used accelStepper, but from the look of your code it will move to 100, then instantaneously move to 200, then 300 etc, without a pause in between individual movements, so it will appear to move directly from it's start position for 500 steps. (And it will keep repeating that indefinitely.) Edit: And I don't think they're absolute positions, I think they're relative to the start position. (But I might be wrong about that.)
No, on closer inspection, because it's looping, it will start a movement, then loop until the distance to go is 0, then depending on where in the loop it is at that moment, it will begin another move. End result is similar to what I first described, but even more out of control.
(I'm getting tired and slow. )
And this:-
if (stepper1.distanceToGo() == 0)
appears to be a check to see if the stepper has finished a move before continuing with the following statement.
this is so much more difficult than I thought it was going to be
I bought 14 of these little motors, in hopes of controlling them freely, but it's not so easy lol
i basically want to control the motor for example
(in absolute position relative to the start position of the stepper)
50 steps forward
100 steps backward
1000 steps forward
400 steps backward
.........
it needs to move in specific amount as i need it
i also have to drive two of these,, so I hope I can use the code I have posted above
dovidu:
i'm going to try that right now, although i think it doesn't have what i need it to do
When trying out a library that you haven't used before, that's the very first thing that you should do.
Study the examples, test the examples, try modifying them to ensure that the results are what you expected, then write your own code, using what you've learned.
There are no doubt plenty of examples online for using that library, too. Just take your time, and make sure you fully understand exactly how everything works.
The documentation says this about runToNewPosition(...):
"Moves the motor (with acceleration/deceleration) to the new target position and blocks until it is at position. "
The problem is the word "blocks". To move two motors virtually simultaneously, you will have to use one of the non-blocking functions (such as run()) in a loop.
You may want to look at the library source code for runToNewPosition(...) and do what it does but do it for two motors.