Coding in Home Position for DC Motor

Using pre-set steps/movement, I am trying to figure out the best way to go about undoing/reversing the steps when a button is pressed. I accumulate the steps and reverse them, but how do I make it so that it goes back to a "home" position. This is a very rough sketch of what I am thinking so far, but not sure if I'm going about it the best way.

Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination

If you are using a normal DC motor then you have no hope of making it retrace its steps accurately let alone moving to a home position.

The motor will move nearly the same amount each time that you apply power for a certain period but nearly is not good enough

The solution is to attach a decoder to the motor so that you can determine exactly how many degrees the motor has moved which can then be repeated or reversed

Sorry about that!

That's an encoder, not a decoder! Specifically a rotary encoder.

So it is