Position sensing using an optical potentiometer