The second ranging action is a process similar to S26, to activate the IRED 4 to emit the predetermined number of pulses, receive the reflected light from the object by the PSD 5, execute a first integral operation (t7-t8 in FIG. 9) for discharging a voltage according to the distance to the object, execute a second integral operation (t8-t9 in FIG. 9), and calculate a second distance value D2 acco