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!