To make the peak value of the driving current of light source smaller than the conventional one and to make the peak value of the light receiving level of light-sensitive elements smaller than the conventional one in order to save power consumption of the device and to improve the precision of measurement, codes of which the bits of the Hadamard codes are shifted by the same bit for each code series having the same bit cycle, or codes of which the bits of a PN code are shifted are used as different codes.