Implementing limit switches on an Alexa controlled CNC drill

I'm currently working on a project in which I have created a CNC drill with each axis controlled by a stepper motor. The functionality of inputting x and y distances for the drill as well as drilling the actual hole have been tested and work. The only issue is there is no true home command in place. Currently, the logic of the system determines the "home" position based off the previous 2 commands. I've ordered some limit switches and am confident in my ability to wire them to the breadboard, but I am not quite sure about the logic of implementing these switches. Since it will be in a loop statement, how can I achieve using the limits of the drill as a home position without the drill getting stuck in this position and not accepting further commands as the limit will be depressed? I was thinking something like a small bounce off of the switch, but again I'm having some trouble nailing down the logic. Any advice is appreciated.

JGD-final.ino (36.5 KB)

The use of home microswitches in your project are only useful if you ALWAYS place what you are drilling in EXACTLY the same position for each thing you are drilling. Is this the case?

Otherwise you need to establish a zero position, both x and y, for the object you are drilling. Do this by manually touching the drill to the x and y edges of the object and recording that position, less 1/2 the drill diameter.

Paul