I originally posted to
https://groups.google.com/forum/#!topic/accelstepper/T_USR692pM0
and was helped out by
https://groups.google.com/forum/#!searchin/accelstepper/360/accelstepper/2xpCtmseXZA/Y_b4RqOdjL8J
and
http://forum.arduino.cc/index.php?topic=246421.0
so I'm on the final stretch.
the code
if(UD1 < pointy1-10 || UD1 > pointy1+10 || LR1 < pointx1-10 || LR1 > pointx1+10){
deltay1 = UD1-pointy1;
deltax1 = LR1-pointx1;
angleindegrees1 = ((atan2(deltay1, deltax1)) *180 / 3.1415926535 +180);
stepperstep1 = map(angleindegrees1, 0, 360, 47, 0);
laststep1 = stepperstep1;
}else{
stepperstep1 = laststep1;
}
if(laststep1 == 47){
stepper1.setCurrentPosition(47);
stepper1.moveTo(stepperstep1);
}
else if(laststep1 == 0){
stepper1.setCurrentPosition(0);
stepper1.moveTo(stepperstep1);
}else{
stepper1.moveTo(stepperstep1);
}
stepper1.run();
works, but whenever I crossover from the first to the last step and vice versa, the speed drops to zero and sometimes it stutters and misses a few steps due to the setCurrentPosition() calls.
If anyone has any polishing, tips or code improvements I'm all ears, thanks!