My first CNC machine Arduino Mega controlled!!!!

I just had a thought. With step/dir motor controllers, you could use one pin for the direction on all a three axes. Since you can only pulse one of the step pins at a time, the other motors wouldn't be affected, and you can run three motors off of four digital pins instead of six. This might be a more efficient method than multiplexing limit switches to squeeze a little more out of the available I/O.