Beginner Project - Controlling a PC fan with Arduino Uno

Hi folks,

It's my first time using arduino, and I want to control the speed of a PC fan for a project.

I've read various things and get confused by different people saying I need external power, the arduino will fry, transistors, opto-isolators, soldering different bits and pieces etc.

This example USB powered computer case fan (arduino) - YouTube seems to work fine in a very simple way without needing to mess about with power supplies.

My question is, does the fan need to be 5 volts or under for the Arduino to power it over USB?

Would this fan be suitable in terms of voltage and the right pins/wires/connections?
http://www.amazon.co.uk/Evercool-50mm-5cm-Volt-case/dp/B00D05ZO12/ref=sr_1_3?s=computers&ie=UTF8&qid=1415751303&sr=1-3&keywords=5+volt+fan

Thanks very much, I'd really appreciate any advice.

USB 2.0 supports 5 Volt @ 200mA if i'm correct. it will be hard to fry anything on usb power. and also, it might be hard to (fully) power an fan (motor) as most of them draw AT LEAST 200 mA's. and i think if you really are afraid to fry anything, i gues you could even try to power the fan on 3.3V pin from arduino ?

the fan you linked to states this:
Current AMP: 0.22 (220mA)

so you will not be able to supply that by USB, though i do think it will spin..
and please check the arduino I/O pins max amp. if i recall correctly their maximums are around 40mA. so im afraid you must use transistors (thats a simple way) rated for 300-500 mA to power on or off the fan, and for the control, i don't know if PWM from arduino is able to control the fan, ill leave that to next poster because i don't know :wink:

psc91
With a typical brushed DC motor (dc motor with two wires), it requires a certain voltage and current to run. The arduino can indeed supply 5 volts, but it can only supply a miniscule amount of current from its output pins, which is typically not enough for DC motors, including your fan's motor (as mentioned by nickn4).

I reckon all you need is one transistor. Here is a bit of an explanation in case you are not familiar with them:
Transistors can be thought of in this application as an electronic on-off switch.
Your typical switch has two terminals and physical button itself. Connect one terminal to the battery and one terminal a lightbulb, then if you flick the button up the lightbulb will turn on, and if you flick the button down, the lightbulb will turn off.
Transistors have 3 terminals, two of them have the same function as the 2 terminals on electric switch, but the third terminal is replaces the physical button of a normal switch. If you output a high voltage to this terminal, then the transistor will turn the lightbulb on. If you output a low voltage, the transistor will turn the lightbulb off.
Additionally, transistors are sensitive to a variable voltage. if you send 50% of max voltage to the third terminal (the one that replaces a button), the lightbulb will be 50% bright. With motors, this will allow you to control the motor's speed.
The reason you need transistors is because the third 'triggering' terminal requires a miniscule amount of current. That way your arduino output is only require to trigger the motor, not to power it, and will then be strong enough.

To complete nickn4's post, the arduino can indeed control the fan speed with PWM. Connect the PWM pin to a transistor, and you can fully control the speed of the fan. PWM is essentially an analogue output, where it can output a specific voltage between 0V and 5V (like 1.5V), instead of just 0V or 5V (On or Off). As I mentioned earlier, by varying the voltage, you can vary the amount of current the transistor allows to flow through, and therefore control the speed of the motor.
TO BE EXACT, arduino's cant actually output anything aside from 0V or 5V, and PWM actually works by rapidly turning on/off a 5V signal, and since it happens so quickly, most sensors will read an analogue voltage. Imagine playing flappy bird, even though you have no joystick control, you can control the height of the bird by rapidly tapping the screen. If you mash the screen the bird will fly high, but depending on how fast you tap it, you will be able to control how high the bird flies. Similarly, the arduino cannot output a specific height for the bird to fly at, but it still can indirectly control that height by tapping the screen faster/slower.

Hope you find this useful!
StefL

StefL provided a very thorough reply. I just wanted to expand with a specific configuration that could drive this setup. You can use an N-Channel MOSFET (a type of transistor) with its Collector connected to ground, Emitter connected to the negative lead of the fan (black, although it may not matter which polarity depending on the fan your choose), and the Gate will be driven by the arduino's pwm pin. The gate it high impedance so very little current will flow out of the pwm pin (this avoids the problem of max current that the arduino pin can provide).

I recommend giving the Wikipedia page on MOSFETs a good read: MOSFET - Wikipedia

There is a picture on the right hand side that illustrates a N-Channel MOSFET driving an LED on the wikipedia page about 1/4 of the way down. You can mimic this setup and replace the series resistor and LED with your fan. The arduino replaces the switch and provides a positive voltage to turn the MOSFET on and a ground level to turn it off.

Thanks folks, very helpful comments. I've ordered a bunch of stuff and will give it a try!