I have a stepper with pointer attached, I know where 0 is with a opto slotted switch.
I have a variable in a rgister which is 0-360 and is the degrees at which the pointer needs to be at.
Getting it to work was no problem, but now I'm thinking of some code that moves the pointer over the shortest distance, ie if the pointer is on 0 and wants to go to 359, at the moment with the code I have it will go clockwise the long way round not just back anticlockwise a degree.
Is there an easy way to calc which direction to go in?
I have a variable in a rgister which is 0-360 and is the degrees at which the pointer needs to be at.
Getting it to work was no problem, but now I'm thinking of some code that moves the pointer over the shortest distance, ie if the pointer is on 0 and wants to go to 359, at the moment with the code I have it will go clockwise the long way round not just back anticlockwise a degree.
Is there an easy way to calc which direction to go in?