Automatic control of fan speed