FAN SPEED CONTROL WITH ARDUINO USING A POTENTIOMETER

Hi guys,

In this weeks post I’ll be showing you guys how to make a speed controlled fan using an arduino. we shall use a pc case fan and control its speed by turning the knob of a potentiometer.

Let us begin

You will require the following parts:

  • Arduino Uno
  • a potentiometer
  • a PC case fan
  • wires
  • breadboard

PWM  and the Arduino

PWM stands for pulse width modulation. if you do not know what pulse width modulation is you can find out more at this link. The arduino has only a few pins that can be used to send PWM signals. these pins can be identified with a ‘~’ symbol next to its no. See the pic below.

arduino pwm.jpg

As you can see from the arduino Uno has 6 pins capable of PWM output. The arduino can send PWM values with a scale of 0-255.  For more details check the program in the last section.

On the other end of the board we have the analog input of the arduino.

Arduino analog input.jpg

These 6 pins on the arduino allow us to connect analog sensors to them. the output recieved from these pins will be scaled from a number ranging from 0-1023.

 The Fan and the potentiometer

Pc case fan.JPG

The fan I am using is an old motherboard fan. some motherboard fans have three pin and some have four pin connector. This fan is the four pin version. You can find more details regarding the pinouts here. This fan requires a 12V input but works pretty well with the 5V output of the arduino. Also we shall not be connecting ‘Sense‘ pin i.e. pin 3. check circuit diagram in the last section.

potentiometer

If you don’t know what the component in the above picture is it is a potentiometer . How it works is this. Connect it properly as the shown in fig. If you rotate the knob You will get an input signal proportional to the amount of rotation.

The final part

  • Connect the parts as per the circuit diagram.

fan control circuit connections

  • You will need to upload the following program to the arduino
int fan = 9; //fan is connected to pin 9 of the arduino

void setup() {
 // initialize serial communication at 9600 bits per second:
 Serial.begin(9600);
 pinMode(fan, OUTPUT); //define pinmode for pin 9. i.e.INPUT/OUTPUT
}

void loop() {
 // read the input on analog pin 0:
 int pot = analogRead(A0); //pot reads analog input A0 value
 int fan_speed = pot * (255 / 1023.0); //this scales the value between 0-255
 analogWrite(fan,fan_speed); //this sends pwm pulse to pin 9 of fan_speed no
 Serial.println(fan_speed); //this prints fanspeed value in serial
 delay(10); // delay of 10 to provide stability
}

 

  • Now rotate the knob of the potentiometer. You should be able to control the speed of the fan through it
  • If you open up the serial port on the arduino IDE  you can see the values of PWM output ranging from 0-255

fan speed working

That’s it for this week, Please like, comment and subscribe . Ill see you guys next week with another project.

Advertisements

3 thoughts on “FAN SPEED CONTROL WITH ARDUINO USING A POTENTIOMETER

  1. Hi,
    Liked your post on bar code reading very much but you could have a problem with fan control using an arduino. Depending on the fan you select the arduino could have an overloaded O/P pin. If memory serves only about 100ma is recommended (could be even less). Better to drive the fan using an NPN transistor with its base fed from the arduino via a suitable resistor. Otherwise you have a burned out arduino.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s