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)