# Arduino Fan Controller This project is an Arduino-based fan controller that allows you to adjust the speed of a 4-pin PWM fan using a push button. It also measures and displays the fan's RPM via the serial monitor. ## Features - PWM control of a 4-pin fan - RPM measurement using the fan's tachometer output - Speed adjustment in 10% increments via a push button - Serial output of current speed and RPM ## Hardware Requirements - Arduino board (Uno, Nano, etc.) - 4-pin PWM fan - NPN transistor (for PWM control) - Push button - Resistors (as needed for button and transistor) - Wires and breadboard ## Pin Configuration - **pwmPin (9):** PWM output to transistor base - **tachPin (2):** Tachometer input from fan - **buttonPin (7):** Push button input ## How It Works - The fan speed is controlled by PWM signal on pin 9. - The push button on pin 7 increases the speed by 10% each press, cycling from 0% to 100%. - The tachometer signal from the fan is read on pin 2 using an interrupt to count pulses. - Every second, the RPM is calculated and printed to the serial monitor along with the current speed percentage. ## Usage 1. Connect the hardware as described above. 2. Upload the `ArduinoFanController.ino` sketch to your Arduino. 3. Open the serial monitor at 9600 baud to view speed and RPM. 4. Press the button to increase fan speed in steps. ## Schematic Below is a simple schematic for connecting the components (updated for a 5V fan, 1kΩ resistor, and two capacitors in parallel to the fan): ``` +5V (Fan Power) | [Fan] | +---+---+ | | | | | +-- PWM (Pin 9, Arduino) via 1kΩ resistor | +------ Tach (Pin 2, Arduino) | GND | [C1] 100uF Electrolytic [C2] 104pF Ceramic (C1 and C2 in parallel to the fan) [Button] | Pin 7 (Arduino) | GND [NPN Transistor] Collector: Fan GND Base: PWM (Pin 9, Arduino) via 1kΩ resistor Emitter: Arduino GND ``` **Notes:** - The fan is powered by 5V. - A 1kΩ resistor is used between Arduino pin 9 (PWM) and the transistor base. - Two capacitors (100uF electrolytic and 104pF ceramic) are connected in parallel to the fan for noise filtering and stability. - The tachometer wire goes directly to Arduino pin 2. - The button is connected between pin 7 and ground, with a pull-up resistor enabled in code. ## Notes - The RPM calculation assumes the fan generates 2 pulses per revolution. - You can modify the code to set the speed via serial input (see commented section in the code). ## License This project is open source and free to use for personal and educational purposes.