Problem programming a conveyor to stop near a proximity sensor

Maybe check out this thread, seems like a similar problem.
https://forum.arduino.cc/index.php?topic=540939.msg3686566#msg3686566