Short- or long-range photoelectric sensors for precise distance measurement