A real-time optical sensor has been integrated into a robot end effector. The sensor consists of a four-element position sensing spot, detector and can control a robot motion in two dimensions (two translational axes or translational and rotational axes). Analogical detection and signal analysis ensure fast response of the sensing system. The detecting system has been connected to the ``Unimation-Puma 600'' robot, through its manual teach box, thus different tasks such as real-time path tracking, spot positioning, and teaching can be achieved. The sensor is simple in design and consequently inexpensive.