A question came up on IRC regarding how to PWM a 3-pin PC fan with an Arduino using analogWrite(). Controlling the fan was seemingly straightforward. The problem was that the hall effect sensor, or TACH signal, was incredibly noisy. The noise made it impossible to measure the fan’s rotation. Working through the question, I found three issues to tackle:
- You need to use a PNP transistor
- Filter capacitors help
- Create a non-blocking RPM measurement (with millis())
This post addresses all three issues regarding how to PWM a 3-pin PC fan with an Arduino.