# Controlling a 4-wired fan PWM Signal using Arduino allows only two settings

I have connected my pwm pin to my arduino like in this tutorial

It's working properly. I can read and set the speed using a sketch from this website:

int fanPulse = 0;
unsigned long pulseDuration;

void setup()
{
Serial.begin(9600);
pinMode(fanPulse, INPUT);
digitalWrite(fanPulse,HIGH);
}

pulseDuration = pulseIn(fanPulse, LOW);
double frequency = 1000000/pulseDuration;

Serial.print("pulse duration:");
Serial.println(pulseDuration);

Serial.print("time for full rev. (microsec.):");
Serial.println(pulseDuration*2);
Serial.print("freq. (Hz):");
Serial.println(frequency/2);
Serial.print("RPM:");
Serial.println(frequency/2*60);

}

void loop()
{
analogWrite(3,20);
delay(5000);
analogWrite(3,50);
delay(5000);
analogWrite(3,100);
delay(5000);
analogWrite(3,200);
delay(5000);
analogWrite(3,255);
delay(5000);
}


It seems to me, like I can only enter values higher than 127 and values lower than 127. There are no steps between them. The fan won't turn slower when I go from 126 to 0 or from 128 to 255.

Some results I get:

100:

pulse duration:19058
time for full rev. (microsec.):38116
freq. (Hz):26.00
RPM:1560.00

0:

pulse duration:19160
time for full rev. (microsec.):38320
freq. (Hz):26.00
RPM:1560.00

127:

pulse duration:9032
time for full rev. (microsec.):18064
freq. (Hz):55.00
RPM:3300.00

255:

pulse duration:9151
time for full rev. (microsec.):18302
freq. (Hz):54.50
RPM:3270.00


Is there some mistake I've made or is it possible my fan won't accept precise values? Can you recommend any 4 wired fans I could use for this or some other way? I thought about using a SG2524N to controll a two wired motor, but I'm not experienced with this. Thanks for your advice.

• Are you sure that pin 3 is a PWM channel on your Arduino? Use a LED to test. Oct 10, 2013 at 1:19
• I'm now using SoftPWM, still no change. I'm going to switch the fan and try again Oct 10, 2013 at 8:20