I have designed a 4-pin PWM fan controller which I then wrote the guide at Fritzing. The fan I used has the following colors: black-yellow-red(PWM)-blue(SENSE)
Now, I have another fan which is black-red-yellow-blue
With my previous code, the RPM is OVF which I can guess it means an incorrect SENS pin is attached to the Uno.
WOW.
Bad idea to PWM the power wire. That will fry the Arduino pin.
That small fan will likely draw >100mA. Way more than the absolute max of 40mA.
Look at the order of the wires in the molex connector.
It's always Ground, 12volt power, speed info, PWM signal.
Connect a 12volt supply to the fan's ground and 12volt wires.
Also connect fan ground to Arduino ground.
Output a ~25kHz PWM signal to the PWM wire.
Connect the speed info (RPM) wire to a digital input with PULLUP enabled.
Leo..
Google 4-pin fan, and look at (molex connector) pictures.
4-pin fans have inbuild (mosfet) speed control (3-pin fans don't).
12volt fan power is always connected to the first two wires.
The black one (first one) is ground/negative, the second one is +12volt.
The third wire is RPM info. To display fan RPM, or to see if the fan is still spinning.
The fourth wire (4-pin fans only) is speed control.
4-pin fans are designed for a 25kHz PWM signal.
25kHz falls outside our hearing, so speed control is silent.
If you use another PWM frequency, you might hear knocking/buzzing.
3-pin fans don't have inbuild speed control.
If you want to preserve RPM info, you have to PWM the +12volt supply, high-side, with a P-channel mosfet or a PNP transistor and a level shifter (5volt to 12 volt).
30herz PWM is normally used for that, because it also falls outside our hearing.
You might still hear slight knocking at low fan speeds.
Two-pin fans are the same as 3-pin fans. Only the speed info pin is missing.
So they can be PWM-ed low-side, with an N-channel mosfet or NPN transistor.
Leo..
One more question:
The fan is a 1.35A one. Should I use a power transistor (BD139) in order to provide the large current? I mean connecting the PWM pin of the arduino (DIGITAL_9) to the base of the transistor and then wire the emitter to the PWM pin of the fan?