The second ranging action is a process of activating the IRED 4 to emit the predetermined number of pulses, receiving the reflected light from the object by the PSD 5, carrying out a first integral operation (t7-t8 in FIG. 9) for discharging a voltage according to the distance to the object, thereafter carrying out a second integral operation (t8-t9 in FIG. 9), and calculating a second distance va