I am trying to build a simple fan controller (single fan). So far I have successfully created a circuit which powers the fan with an external 12v DC adapter and added a transistor (NPN) to switch it on and off. The transistor is connected to a PWM port on the Arduino.
HIGH on the port the fan works perfectly at high speed, but when I want to lower the speed (say
analogWrite(fanPin, 150)) it starts to make a humming noise. I believe this is caused by the use of PWM.
What is the best way to control the speed of the fan without (too much) noise?
ps. The fan is a Cooler Master 3-wire PC fan. Transistor is a P2N2222A.
Update: Here is the schema I am using: