Keywords: Arduino fan control, PWM, transistor, temperature fan control
Controlling the speed of a DC fan is one of the most practical applications for beginners working with Arduino. Pulse Width Modulation (PWM) allows us to adjust the speed of a fan smoothly and efficiently without expensive hardware.
In this tutorial, you'll learn how to:
-
Use an Arduino to control a 2-wire DC fan
-
Apply PWM to change speed
-
Build the full circuit with a transistor and diode
What You'll Need
| Component | Quantity |
|---|---|
| Arduino Uno | 1 |
| 2-wire DC fan (5V–9V) | 1 |
| NPN transistor (e.g. 2N2222 or BC547) | 1 |
| 1kΩ resistor (base resistor) | 1 |
| Diode (1N4007 or 1N5819) | 1 |
| Breadboard and jumper wires | — |
| External power supply (9V battery or adapter) | 1 (optional for 9V fans) |
Circuit Diagram
Explanation:
-
The transistor acts as a switch. It receives a PWM signal from Arduino on its base through a 1kΩ resistor.
-
The diode is connected across the fan terminals in reverse bias to protect from voltage spikes (flyback diode).
-
The fan is powered from the 9V source (or Arduino 5V for smaller fans).
📄 Arduino Code
Tips:
-
Use analogWrite() to generate PWM on pins 3, 5, 6, 9, 10, or 11.
-
Don't power a 9V fan directly from Arduino — use an external source with a shared GND.
Don't power a 9V fan directly from Arduino — use an external source with a shared GND.
Don't power a 9V fan directly from Arduino — use an external source with a shared GND.
Conclusion
Using PWM with Arduino to control a fan is simple and educational. This same principle can be applied to control LEDs, motors, heaters, and more. For automatic control, you can even combine this with a temperature sensor like LM35 — which we’ll cover in a future tutorial.
No comments:
Post a Comment