Added the LDR logic for end of maze detection.