PURPOSE: To automatically set up a threshold by allowing an object to pass the vicinity of a detector switch.
CONSTITUTION: An object detecting area is irradiated with light from a projection drive part 12 through a projection part 13. The receiving light quantity obtained by a photodetecting part 14 is differentiated by a differential processing part 15 and the differentiated value is compared with a differential threshold. When the differentiated value exceeds the threshold, the value is divided, and in the case of less than the threshold, plural receiving light quantity levels are stored in a receiving light quantity/differential value storing part 17. Thus plural thresholds can be automatically set up to their intermediate value by a threshold calculating part 18 based upon plural obtained levels.