Fan control help needed

Hi guys, I'm posting for the first time but I have been reading the forums alot and have learned alot aswell. But now I've come to an impass and I need some help.

My problem is that I'm trying to control a computer fan(Arctic Cooling F8 PWM) with the PWM pin from an Arduino Due but nothing happens. I'm sure I've gotten the connections and the code right since it works on a different fan.

The fan itself turns on when connected to a 12V battery, but analogWrite() does nothing. Now I've done some research but I'm not really sure what I'm looking at. There's alot of mention of PWM frequency which I don't fully understand. I read that most of the CPU fans work on a 25kHz frequency but I'm not sure what this has to do with my Due.

Basicly what I need is that I need to understand how all this works, any explanations and documentation are greatly appreciated.

What code are you trying to run on the Due?

int LDR = A0;                 
int LDRValue = 0;                    
int light_sensitivity = 750;  
 
void setup()
  {
    Serial.begin(9600);           
    pinMode(13, OUTPUT);    
  }
 
void loop()
  {
    LDRValue = analogRead(LDR);        
    Serial.println(LDRValue);                  
    delay(50);                                              
 
    if (LDRValue < light_sensitivity) 
      {
         analogWrite(13, 100);
        }
        else
        {
          analogWrite(13, 200);
          }
          }

This is the code I got running. Basicly it's hooked up to a lightresistor so when the lights dim, the fan turns on. Like I mentioned earlier it works on another CPU fan I got, the problem might be the PWM frequency.

how is all this wired ?
could you post a schematic ?

alnath:
how is all this wired ?
could you post a schematic ?

The wiring:
http://s30.postimg.org/lu18460jl/sensor_fan_control.jpg

IIRC 3 pin fans cannot be controlled with PWM through the fan itself.

If it's a four pin fan then you need a common ground between the Arduino and the fan.

If it's a 3 pin fan you can still control it via PWM, but you will need to add a transistor to switch it via PWM.

Sorry, I forgot to add the common ground. It is a 4 pin fan. I'll try the transistor and see if it helps.

monkeyhacker:
IIRC 3 pin fans cannot be controlled with PWM through the fan itself.

If it's a four pin fan then you need a common ground between the Arduino and the fan.

If it's a 3 pin fan you can still control it via PWM, but you will need to add a transistor to switch it via PWM.

Sorry for the late reply, I added a TIP120 transistor and some diodes and got it to work. Thank you very much for the tip!