A sensor, measuring physical quantity based on a set value affecting an output value of the sensor, wherein the sensor comprises: an operator that accepts a mechanical operation of a user, and generates an operation input value corresponding to the operation; a communication portion that receives a communication input value; and a setting portion that updates the set value according to a later input one of the operation input value and the communication input value, wherein the sensor is characterized by: further comprising a measuring portion that projects and receives light, wherein the projected light or the received light is processed by according to the set value, and wherein the setting portion samples the operation input value with a fixed sampling cycle, when an absolute value of a difference between the operation input value sampled at a determination starting time and the operation input value sampled from the determination starting time to a time prior to the sampling cycle, i.e., a reference value, is equal to or above a specified value, the setting portion starts counting the number of times the absolute value of a difference between the operation input value sampled at a time after the determination starting time and the reference value is equal to or above the specified value as a number of sampling the operation input value, the setting portion updates the set value to the operation input value at a time when the number of sampling the operation input value reaches a specified number, and the setting portion stops counting the number of sampling the operation input value and sets the number of sampling the operation input value as 0 when the absolute value of a difference between the operation input value sampled at a time after the determination starting time and the reference value is less than the specified value. an operator that accepts a mechanical operation of a user, and generates an operation input value corresponding to the operation; a communication portion that receives a communication input value; and a setting portion that updates the set value according to a later input one of the operation input value and the communication input value, wherein the sensor is characterized by: further comprising a measuring portion that projects and receives light, wherein the projected light or the received light is processed by according to the set value, and wherein the setting portion samples the operation input value with a fixed sampling cycle, when an absolute value of a difference between the operation input value sampled at a determination starting time and the operation input value sampled from the determination starting time to a time prior to the sampling cycle, i.e., a reference value, is equal to or above a specified value, the setting portion starts counting the number of times the absolute value of a difference between the operation input value sampled at a time after the determination starting time and the reference value is equal to or above the specified value as a number of sampling the operation input value, the setting portion updates the set value to the operation input value at a time when the number of sampling the operation input value reaches a specified number, and the setting portion stops counting the number of sampling the operation input value and sets the number of sampling the operation input value as 0 when the absolute value of a difference between the operation input value sampled at a time after the determination starting time and the reference value is less than the specified value. further comprising a measuring portion that projects and receives light, wherein the projected light or the received light is processed by according to the set value, and wherein the setting portion samples the operation input value with a fixed sampling cycle, when an absolute value of a difference between the operation input value sampled at a determination starting time and the operation input value sampled from the determination starting time to a time prior to the sampling cycle, i.e., a reference value, is equal to or above a specified value, the setting portion starts counting the number of times the absolute value of a difference between the operation input value sampled at a time after the determination starting time and the reference value is equal to or above the specified value as a number of sampling the operation input value, the setting portion updates the set value to the operation input value at a time when the number of sampling the operation input value reaches a specified number, and the setting portion stops counting the number of sampling the operation input value and sets the number of sampling the operation input value as 0 when the absolute value of a difference between the operation input value sampled at a time after the determination starting time and the reference value is less than the specified value.