Arduino with fan (Controlling a Fan with Arduino)

Hi everybody! I have an old pc fan that works at 12 V. I want to connect it to an Arduino Uno and turn it of and of with an IRFZ44N mosfet and 2 tactile switches. When I push one of them, the fan starts, and when I push the other, the fan stops. Can you help me with some code and a wiring diagram ? Please , help me !

You can use this circuit for on/off control and also speed control using PWM

For code I'd suggest you start by getting the blink sketch to work - then add code to read your switches - which you connect like this:

Thanks ! I replace the motor with the fan, no ? And can I add a potentiometer to change the RPM ? I tried this an entire day and it didn't work and I need to finish it untill tomorrow

Let's see what you produced in that time... and what happened. "it didn't work" tells us nothing.

can I add a potentiometer to change the RPM ?

I suggest you make the basic sketch work before you worry about that.

1 Like

I tried to connect the Uno with the fan with l298n, drv883 or transistors and control the pwm with a potenitometer and the fan was turning max 5 degrees. Also I tried using a Pico W and that didn't worked rather(I thot that the Arduino was damaged, but I don't think so, so I'm gonna use it now).

You forgot to post the current code, in code tags. You also forgot to post a wiring diagram (schematic).

Also, you failed to explain the problem, instead just repeated, "didn't worked".

I know, but I don't have the project now, I disassembled it

Great! Now you don't need any code!

1 Like

I need code right now, but it is different from that one anyways, and it was clearly wrong so it is useless

And for this one I will assemble it and then try to write some code

I'm sorry to hear that. Please post the code that you wrote.

The code I've used was for controlling a dc motor, nothing special

Then post a schematic. You should have one if you plan to assemble anything.

I know, but i think i can use one from a DC motor

Except that it didn't work? :slight_smile:

Because, first, I will try with a DC motor

Good. I give you all my luck and encouragement. Go for it!

Yes, I don't know why, maybe mecause I was too tired and didn't make the connections write

Possibly. Or it could be gremlins from another galaxy.

Thanks for the support! I will try it and tell you if anything is not working, maybe you can help me