[AMENDED topic] Detecting an Emergency Stop on Arduino

The simple, non-blocking state-machine is your friend.