Conecting cpu fan?

Hi,
today I took the cpu fan from an older computer and connect it to my arduino to control it.
It has 4 pins and I discovered the vcc, graund and signal (I think), the other must be for rpm readings, so I connect vcc to 5v, the graund to gnd and the signal to pin 6.

It work perfectly, my question is if can I damage my arduino uno r3 by connecting the signal directly into pin 6??

Thanks in advance.

This shows the connections

This shows the connections for a 4 pin fan
http://www.allpinouts.org/index.php/Motherboard_(CPU)_4_Pin_Fan

You probably dont need to use the control pin, just connect it as in the first link Ive posted.

Thanks, it work better that way (the fan was able to spin faster)!
But my fan has 4 pins, I connect the vcc, gnd, and control, where should I connect the sense pin for readings?
an analog pin or a digital pin?

Thanks for replying.

In the diagram of the first link, its shows you (Arduino pin2) where to connect the sense wire.

This allows you to read the RPM of the fan, you then use this to control an arduino PWM output pin to an FET transistor to control the speed of the fan motor.

Theres loads of tutorials on how to drive a motor with an FET, heres just one of them
tutorials
http://bildr.org/2012/03/rfp30n06le-arduino/

For your four pin fan you can ignore the (Control) Blue wire connection.

Lakes:
For your four pin fan you can ignore the (Control) Blue wire connection.

Not if you want to PWM the speed and read the RPM simultaneously. In that case you need to supply the fan thru the regular power and control the speed with the BLUE control wire. That way, the RPM sense wire circuitry will always be powered and able to give you reliable information.

Control wire PWM Frequency: Target frequency 25 kHz,acceptable operational range 21 kHz to 28 kHz

Youd have to change the Arduinos PWM frequency to control the fan this way or write a custom PWM function into the sketch.

You can do this
http://playground.arduino.cc/Code/PwmFrequency
but it messes with other functions.

Depends on what the OP needs, for example, for manual control connect a pot to A0 and use that to control the PWM (Fan Speed)

Lakes:
Control wire PWM Frequency: Target frequency 25 kHz,acceptable operational range 21 kHz to 28 kHz

Youd have to change the Arduinos PWM frequency to control the fan this way or write a custom PWM function into the sketch.

You can do this
Arduino Playground - PwmFrequency
but it messes with other functions.

Depends on what the OP needs, for example, for manual control connect a pot to A0 and use that to control the PWM (Fan Speed)

Or you could do this, it hijacks Timer2. It will PWM a fan at exactly 25kHz and run a sample showing how to read the fan RPM and print it out:

const int PWMPin = 3;

void setup() {
// generate 25kHz PWM pulse rate on Pin 3
  pinMode(PWMPin, OUTPUT);   // OCR2B sets duty cycle
// Set up Fast PWM on Pin 3
  TCCR2A = 0x23;     //0x23 COM2B1, WGM21, WGM20 
// Set prescaler  
  TCCR2B = 0x0C;   //0x0A WGM21, prescaler = /8
// Set TOP and initialize duty cycle to zero(0)
  OCR2A = 79;    // 79 TOP DO NOT CHANGE, SETS PWM PULSE RATE
  OCR2B = 79;    // duty cycle for Pin 3 (0-79) generates 1 500nS pulse even when 0 :(

  Serial.begin(57600);
}

void loop() {
  
  unsigned long x;
  unsigned int rpm;
  
  if((unsigned)OCR2B > 79){
    OCR2B = 79;
  }  
  delay(1000);
  Serial.print(OCR2B);
  Serial.print(" ");
  x = pulseIn(11, HIGH);
  Serial.print(x);
  x += pulseIn(11, LOW);
  Serial.print(" ");
  Serial.print(x);
  rpm = (1000000 * 60) / (x * 2); 
  Serial.print(" ");
  Serial.println(rpm);
  OCR2B--;
}

You connect the Blue fan CONTROL wire to Pin 3 and the Green SENSE wire to pin 11. You set OCR2B to a value from 0 to 79 to set the PWM duty cycle. The loop() will start the fan at full RPM and then gradually decrease it while constantly reporting the RPM. Fans run on 12V, not 5V and you may need a pull-up to +5V on the Green RPM sense wire.

Has someone tested the code from afremont ?

I'm here with a cpu fan, an Arduino and it doesn't seem to work. On the brightside, the fan does seem to turn on itself when it's powered, without anything comming in on pin 3 or 11.