An electronic device comprising: an optical module configured to radiate light to an object and thereby detect a distance to the object from the electronic device by using light reflected from the object, the optical module comprising one or more light sources , a light path change element configured to change a path of light from the one or more light sources and to deliver the light to the object, a distance detection sensor configured to receive light reflected from the object and to detect the distance to the object from the electronic device based on the reflected light, and a rotation element configured to rotate the light path change element; and a processor configured to: control the optical module to detect the distance to the object from the electronic device, and determine touch information and/or gesture information of the object based on information about the detected distance to the object, characterized in that the processor is further configured to: adjust a control factor for controlling the optical module based on environment information, the environment information comprising a type of an application used together with the electronic device or a type of an application associated with motion of the object, wherein the control factor comprises at least one of a strength of the one or more light sources , and a rotation speed of the rotation element . an optical module configured to radiate light to an object and thereby detect a distance to the object from the electronic device by using light reflected from the object, the optical module comprising one or more light sources , a light path change element configured to change a path of light from the one or more light sources and to deliver the light to the object, a distance detection sensor configured to receive light reflected from the object and to detect the distance to the object from the electronic device based on the reflected light, and a rotation element configured to rotate the light path change element; and a processor configured to: control the optical module to detect the distance to the object from the electronic device, and determine touch information and/or gesture information of the object based on information about the detected distance to the object, characterized in that the processor is further configured to: adjust a control factor for controlling the optical module based on environment information, the environment information comprising a type of an application used together with the electronic device or a type of an application associated with motion of the object, wherein the control factor control the optical module to detect the distance to the object from the electronic device, and determine touch information and/or gesture information of the object based on information about the detected distance to the object, characterized in that the processor is further configured to: adjust a control factor for controlling the optical module based on environment information, the environment information comprising a type of an application used together with the electronic device or a type of an application associated with motion of the object, wherein the control factor comprises at least one of a strength of the one or more light sources , and a rotation speed of the rotation element . <EOS>