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.

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.

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

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.

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.

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

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