Control motor based on direction