Generally, electronic devices produce more heat. So this heat should be reduced in order to protect the device. There are many ways to reduce this heat. One way is to switch on the fan spontaneously. This article describes a circuit that automatically, switches the fan when it detects the temperature inside the device greater than its threshold value.
Temperature Controlled DC Fan Circuit Principle:
The main principle of the circuit is to switch on the fan connected to DC motor when the temperature is greater than a threshold value.
The microcontroller continuously reads temperature from its surroundings. The temperature sensor acts as a transducer and converts the sensed temperature to electrical value. This is analog value which is applied to the ADC pin of the microcontroller. The ATmega8 microcontroller has six multiplexed ADC channels with 10 bit resolution. The analog value is applied to one of the input ADC pins. Thus conversion occurs internally using successive approximation method. For ADC conversion, internal registers should be declared. The ADC pin outputs a digital value. This is compared with the threshold value by the controller which switches the fan if value is greater than threshold.
Read the rest here.