Thanks,my question is more of like the third point,i still havent yet figured it out,so I am asking,sorry if this is a stupid question.
Have you tried this? If so, what part do you run into problems with?
- initialize a variable saying "motor is at position 0" on start-up.
- For each step it takes in the "forward" direction, add one to the variable.
- For each step it takes in the "backward" direction, subtract one.
- to control the motor, send not a direction ("forward") but a target ("37").
- in the loop, if the motor value is less than the target, step forward once; if the motor value is greater than the target, step backward once; else hold.