Hi everyone, I just made this simple led dimmer using Arduino Nano Every and IRF520N mosfets.
I tried on breadboard and I never had any error or problem so I decided to make a real pcb as I need to use them in my house.
I've just soldered every component on one of them and after a bunch of minutes the led strips (3x 1m 12v white led strip) start flicker and randomly one of them switch off.
I share with you my schematic and code (the RTC module on them is used to make them dimming following the sun.
Errata corrige: I realized that pin D2 isn't PWM, so I bypass it (cut it from the Arduino Board) and connect the "Uscita1" output to pin D6 with a flying wire.
Not critical, but you have the 10k on the wrong side of the 220 Ohm resistor.
You do not want to pull down the FET gate. The 10k resistor is simply there to hold the Arduino pin LOW until the microcontroller boots and sets it to OUTPUT. The problem is the Arduino, so that is where you put the pull-down resistor.
So, your LED strip draws substantially less than one Amp? Because the IRF520 is not a logic-level FET and will not turn on fully at 5 V.
Hi Paul, I dont see why it makes ANY difference - can you explain please?
I've not much experience with MOSFETS - so can someone also exlpain why the 220 E resistor is needed as I understood MOSFETs are voltage driven and more or less infinite input resistance?
The flickering is strange. I don't know how it could be explained by a missing Gate resistor. IMO it is either a bug (but your code is so simple it seems nearly impossible) or some other HW problem. I suspect something heats up and works wrong. Power source or some contact? That is why I asked about the on/off control. If you turn the LEDs on and keep them on for "couple of minutes" there is no flickering?
Well, I did explain the reason for placing it correctly. It may make a difference if the two resistor values are within a couple of orders of magnitude, particularly when you are using the FET with a marginal gate voltage as you are with the IRF520. It is simply a matter of good engineering design.
As the article offered no doubt explains, and it is a point of common argument over the years here, the FET has more or less infinite input resistance but nevertheless substantial capacitance which matters when driven with AC (i.e., PWM).
What the article forgot to mention is the fact you want to (dis)charge the Gate capacitance as fast as possible particularly when PWMing. The article suggests 1k resistor as optimal Gate resistor. That is at least 5 times more than needed meaning 5 times slower switching and 5 times higher switching losses.
Of course LEDs are very forgiving load for a MOSFET (or other switch) and the switching losses are always low compared to motors and similar.
Well, of course I left that bit for you; I was only addressing my original point.
To be fair, it very much depends on how many LEDs. It's just a matter of the total current, or are you thinking of the extra Volt due to the commutation diode on an inductive load?