Temperature-Controlled Fan Using Arduino
1. Introduction
This project involves building a temperature-controlled fan using an Arduino board. It demonstrates how
temperature sensors and microcontrollers can be used to automate fan speed based on real-time
temperature readings. It is ideal for beginners in embedded systems.
2. Components Required
- Arduino UNO or Nano
- LM35 Temperature Sensor or DHT11
- DC Fan (5V)
- NPN Transistor (2N2222 or TIP120)
- Diode (1N4007)
- Resistors (1k, 10k)
- Breadboard and Jumper Wires
- Power Supply (9V battery or Adapter)
3. Circuit Description
The LM35 sensor reads the ambient temperature and outputs an analog voltage proportional to the
temperature. This analog signal is read by the Arduino and converted to a temperature value. The Arduino
then uses Pulse Width Modulation (PWM) to control the speed of the fan based on temperature ranges. A
transistor is used to handle the higher current required by the fan.
4. Arduino Code
Temperature-Controlled Fan Using Arduino
The Arduino reads the LM35 sensor value and adjusts the fan speed accordingly. The following logic is used:
- Below 30°C: Fan is off
- 30-40°C: Fan at low speed
- 40-50°C: Fan at medium speed
- Above 50°C: Fan at high speed
5. Sample Code
const int tempPin = A0;
const int fanPin = 9;
void setup() {
pinMode(fanPin, OUTPUT);
[Link](9600);
void loop() {
int tempReading = analogRead(tempPin);
float voltage = tempReading * (5.0 / 1023.0);
float temperatureC = voltage * 100;
if (temperatureC < 30) {
analogWrite(fanPin, 0);
} else if (temperatureC < 40) {
analogWrite(fanPin, 100);
Temperature-Controlled Fan Using Arduino
} else if (temperatureC < 50) {
analogWrite(fanPin, 180);
} else {
analogWrite(fanPin, 255);
delay(1000);
6. Conclusion
This project successfully demonstrates how an Arduino can be used to control the speed of a fan based on
ambient temperature using PWM. It is a practical example of automation and is a useful foundation for future
IoT or smart home projects.