To thrive, organisms must maintain physiological and environmental variables in suitable ranges. Given that these variables undergo constant fluctuations over varying time scales, how do biological control systems maintain control over these values? We explored this question in the context of phototactic behavior in larval zebrafish. We demonstrate that larval zebrafish use phototaxis to maintain environmental luminance at a set point, that the value of this set point fluctuates on a time scale of seconds when environmental luminance changes, and that it is determined by calculating the mean input across both sides of the visual field. These results expand on previous studies of flexible phototaxis in larval zebrafish; they suggest that larval zebrafish exert homeostatic control over the luminance of their surroundings, and that feedback from the surroundings drives allostatic changes to the luminance set point. As such, we describe a novel behavioral algorithm with which larval zebrafish exert control over a sensory variable.