"Directional Switch" Design

A single optointerrupter (A) at the beginning of travel point, a pair of optointerrupters (B and C) at the midpoint, and a single optointerrupter (D) at the end of travel point.

Detect the transition of B = true followed by C = true, turn light on, detect transition of D = true, turn light off.

Remove A from system altogether, as it turns out that it is not required. Might come in handy for some other project.