
Bu projeyi gerçekten kurmak istersen parçaları hobidevre.com'dan temin edebilirsin →
Build it for real
To build this project for real, get the parts from hobidevre.com → hobidevre.com →
More build guides: hobidevre.com/blog
Create a free account — save your progress and get more circuits →
No installationWhat is it for?
In this project a temperature sensor reads the ambient temperature as an analogue voltage, and the Arduino uses that value to set fan speed with PWM. As the temperature rises the fan speeds up; as it cools the fan slows down or stops. Because the fan cannot be driven directly from Arduino pins, an NPN transistor acts as a low-side switch and a 1 kiloohm base resistor protects it. A flyback diode across the fan absorbs the spike generated when the transistor switches off. The fan is powered by a separate 12V source whose negative terminal shares a common ground with the Arduino. The sensor is powered from 5V and its output goes to an analogue input. A red LED and 220 ohm resistor show an over-temperature warning. This is a simple model of computer cooling and cabinet ventilation systems.
Parts list
The following components are used to build this project:
- Arduino Uno × 1 — Reads the temperature and generates the PWM speed signal.
- Temperature sensor × 1 — Converts temperature into an analogue voltage.
- NPN transistor × 1 — Switches the fan current.
- Fan motor × 1 — The ventilation load.
- 1N4007 diode × 1 — Suppresses the coil voltage spike.
- 12V supply × 1 — Separate power source for the fan.
- 1kΩ resistor × 1 — Limits the base current.
- 220 Ω resistor × 1 — Limits the warning LED current.
- Red LED × 1 — Gives an over-temperature warning.
- Ground connection × 1 — Common reference for all ground terminals.
Build it step by step
- Place the Arduino, sensor, transistor and fan; connect GND to common ground.Tip: set up the common ground first.
- Connect the sensor power, output and ground pins in order.Tip: the output pin must go to the analogue input.
- Connect the 12V supply positive to the fan positive and its negative to common ground.Tip: never take fan power from the Arduino.
- Connect the flyback diode across the two fan terminals, with the cathode on the positive side.Tip: check the diode polarity.
- Connect the fan negative to the transistor collector and the emitter to ground, then link the PWM pin to the base through the 1kΩ resistor.Tip: the base resistor is essential.
- Add the 220 Ω resistor and red LED on the warning branch, upload the code and watch fan speed change with temperature.Tip: the PWM ratio should rise as temperature increases.
How it works
A temperature sensor raises its output voltage in proportion to temperature. The Arduino reads this voltage at an analogue input and adjusts the PWM duty cycle accordingly, changing the average voltage at the motor and therefore the fan speed. The transistor converts the Arduino weak PWM signal into the current the fan needs. The 1 kiloohm base resistor protects the transistor from excess current. When the fan coil current is interrupted it generates a reverse voltage; the parallel flyback diode dissipates that energy and protects the transistor. The grounds of the Arduino, sensor, transistor and 12V supply must be common, otherwise the analogue reading and PWM reference drift.
Layout tip: the Arduino is at the top left with the sensor beside it; the transistor and fan are on the right. Sensor output goes to the analogue input, fan power comes from the 12V supply, and all grounds share one point.
What you learn
- Maps an analogue sensor reading to a PWM output.
- Relates temperature to fan speed.
- Explains why a flyback diode is needed.
- Applies a common ground with multiple supplies.
Tips
- Place the diode close to the fan.
- If the fan does not turn, check the base resistor and collector connection.
- The threshold temperature can be changed easily in the code.
- The LED must never be connected without its series resistor.
Try it yourself
- Automatic speed: Warm the sensor and observe that the fan speeds up. The fan speeds up as temperature rises.
- See the warning: Check that the red LED lights when the threshold is crossed. The LED lights above the threshold with the 220 Ω resistor fitted.
Getting the parts
If you want to build this project in real life, you can get the parts from hobidevre.com.
hobidevre.com · more build guides
Frequently asked questions
What is this circuit for?
It automatically adjusts fan speed from a temperature sensor using an Arduino PWM output.
How does the circuit work?
The sensor voltage rises with temperature and is read at an analogue input; the Arduino changes the PWM duty cycle, and a transistor switches the fan current from a separate 12V supply. A base resistor protects the transistor and a flyback diode absorbs the coil spike.
What is the expected result?
Fan speed follows temperature, the warning LED lights above the threshold, and the diode and common ground are complete.