Home‎ > ‎Inspiration corner‎ > ‎

Controlling computer fans


How to control a CPU fan:

This is how you can control the 4 wire CPU fans. (so this is NOT about the 3 wire ones)
int pwmPin = 9;      // digital pin 9
int pwmVal = 10;

void setup()
{
  pinMode(pwmPin, OUTPUT);   // sets the pin as output
  Serial.begin(9600);
}

void loop()
{
  if (pwmVal != 255) {
         analogWrite(pwmPin, pwmVal);
         //pwmVal += 10;
         Serial.print(pwmVal);  // Print red value
         Serial.print("\n");    // Print a tab
  } else {
         Serial.print('at max high');  // Print red value
         Serial.print("\n");    // Print a tab
  }
  delay(1000);
}
enter image description here

and also look at this to include a temperature sensor:

http://alan-parekh.com/projects/pwm-fan-controller/