

A fan is an electromechanical device designed to create airflow, which is essential for cooling or ventilating an area. In electronic systems, fans are commonly used to dissipate heat generated by components such as processors, power supplies, and other heat-sensitive devices. Proper cooling ensures the longevity and reliability of electronic equipment.
The Arduino Nano can be used to control a fan for various applications, such as temperature-based cooling systems, automated ventilation, or custom projects requiring airflow management.








Below are the general specifications for a typical DC fan compatible with Arduino Nano:
| Parameter | Value |
|---|---|
| Operating Voltage | 5V or 12V (depending on the fan) |
| Current Consumption | 100mA to 300mA |
| Power Rating | 0.5W to 3.6W |
| Speed | 2000 to 5000 RPM |
| Airflow | 10 to 50 CFM (Cubic Feet/Minute) |
| Connector Type | 2-pin or 3-pin |
For a 3-pin fan, the pinout is as follows:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | VCC | Power supply (5V or 12V, depending on the fan) |
| 3 | Tachometer | Optional signal pin for speed monitoring (RPM output) |
For a 2-pin fan, the pinout is simpler:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | VCC | Power supply (5V or 12V, depending on the fan) |
To control a fan using an Arduino Nano, you can use a transistor or MOSFET as a switch, since the Nano cannot directly supply the current required by the fan. Below is a step-by-step guide:
Components Required:
Circuit Diagram:
Arduino Code: Below is an example code to control the fan using PWM (Pulse Width Modulation) for speed control:
// Define the pin connected to the transistor or MOSFET
const int fanPin = 9; // PWM pin on Arduino Nano
void setup() {
pinMode(fanPin, OUTPUT); // Set the fan pin as an output
}
void loop() {
// Example: Gradually increase and decrease fan speed
for (int speed = 0; speed <= 255; speed++) {
analogWrite(fanPin, speed); // Set fan speed (0-255)
delay(10); // Small delay for smooth speed transition
}
for (int speed = 255; speed >= 0; speed--) {
analogWrite(fanPin, speed); // Decrease fan speed
delay(10); // Small delay for smooth speed transition
}
}
Fan Not Spinning:
Fan Spins at Full Speed Only:
Fan Produces Noise:
Arduino Resets When Fan Starts:
Q: Can I connect the fan directly to the Arduino Nano?
A: No, the Arduino Nano cannot supply enough current to drive a fan directly. Use a transistor or MOSFET as a switch.
Q: How do I monitor the fan's speed?
A: If your fan has a tachometer pin, connect it to a digital input pin on the Arduino Nano and use an interrupt to measure the RPM.
Q: Can I use a 12V fan with the Arduino Nano?
A: Yes, but you must use an external 12V power supply and ensure proper connections with a transistor or MOSFET.
Q: What is the purpose of the diode across the fan terminals?
A: The diode protects the circuit from voltage spikes caused by the fan's motor when it turns off.