A fluid dispenser with a pump mechanism that dispenses fluid when activated. A light sensor detects light in or around the fluid dispenser, and a controller controls a function of an electronic component of the fluid dispenser based on detection data received from the light sensor.