reverses direction if an end switch is triggered