The present invention concerns a computer implemented method for controlling a device (40) adapted for projecting a light beam on at least a part of an eye of a wearer, the device (40) having an optical module comprising a light source (52), a pupil being defined for the part of the eye, the method comprising a step of providing the size of the pupil, determining a command law of the radiant power of the light source (52), the command law being determined on the provided pupil size, and sending the determined command law to the light source (52).