I'm going to be controlling and driving 8 PC-style fans from an Arduino project, and want to use PWM to vary the speed of the fans.
I've seen several examples that use an optocoupler (or even a relay) to isolate the 5.5V Arduino side from the 12V fan side. Is that really necessary? Can I not drive this through a simple transistor only?
Either way can work. If you use a transistor switch then the negative terminal of the +12vdc voltage source must be wired to an arduino ground pin to function. If you use a opto-isolator chip then there is no need (and no point) in connecting the two ground points together.
Cool, thanks. Everything is being powered from a PC power supply, so I was envisioning all the grounds being tied together, and the Arduino being powered from an LM317 voltage regulator.
Sorry for digging this topic up, but is this diagram really correct?
Shouldn't the diode be connected in parallel with the fan, and not with the transistor?
I would agree with you on that Rubid.
Little funny to use a LM317 for a regulator, fixed 5v like LM7805 would require less parts, just a couple of caps.
When using the following code I get the fan spinning at 100%
speed...cool, only im really interested in using PWM to vary the speed. (I know this board isn't for code, but its a very simple question I'm assuming)
int fan = 3;
void setup() {
Serial.begin(9600);
pinMode(fan, OUTPUT);
}
void loop() {
analogWrite(fan, 1023);
}
This however will not spin with lower values, I get a 9 second gap of no spinning of the fan. The fan will not spin even with a manual push.