Yeah, ignore the trolls. Do you plan to use a 4-wire fan which has a separate PWM pin, or do you want to chop the power supply to the fan with your own transistor?
In the 4-pin case it is kind of easy and in the manual case it's fine as long as you don't want RPM measurements also. Chopping the fan's power pin will impose that PWM waveform onto the tachometer output, so you won't really be able to tell how fast the fan is going. I spent a fair bit of time designing an analogue circuit to circumvent that problem but it fails because at low duty cycles, the capacitor internal to the fan discharges rapidly so you get no tacho output at all even if the fan is running.
4-pin fans have a "minimum speed" (typically about 500RPM) which they will go to if you hold the PWM pin down, i.e. you can't get them to slow all the way to zero without killing the power. But they produce a reliable tacho output at all speeds.
The big physical wrinkle is PWM frequency. The arduino default is about 490Hz, which you can hear as an annoying whine. You probably want to reprogram timer2 to produce PWM at 31kHz or 62kHz and use that signal. A very-low (eg 5Hz) PWM frequency is little better than 500Hz because each PWM edge is still audible as a click. You must use a high PWM frequency to get a silent fan.
In terms of the tacho output, note that the fan is 12V and the arduino is NOT, therefore you should put a diode between the tacho pin and your arduino speed-input pin (anode on the arduino side). That means the fan can pull the pin down, but cannot pull it up past 5V and damage the arduino by feeding 12V into VCC through the pin-protect diode. Enable the internal pin pull-up by writing a 1 to it after setting it as an input. Similarly for driving the PWM pin on a 4-pin fan, use a BC548 or similar to make an open-collector output. See the attached schematic - it can disable the fan entirely with a high-side transistor, controls the speed using the fan's PWM input, and monitors the speed from the tacho pin.
You probably want to use Timer 1 (16 bit) to measure the fan's tacho period. Requires a customer interrupt handler for the timer.
If you get stuck, I have a sketch matching the above schematic that I can supply; it includes two nested PID loops to control the fan to achieve a particular temperature, as sensed using a pair of DS1620. It's designed for an audio amplifier, hence the "remote input", "mute relay" and load shutdown signals.
fancontrol.pdf (69.3 KB)