First project 99% working, minor gremlin

Using defines will encourage best practices.

I would add some debug lines to your code so that you can see what is happening. You have a lot of if then logic going on and my guess is the logic is getting messed it somewhere.

It could also be your wiring, either with one of the endstops or the button but I think software is most likely.