Problem when controlling RGB led strip with Arduino

I want to build a controlling device for RGB led strip as a fun project.
Currently I am doing the breadboard prototype. Here is the diagram


The mosfets I use are IRLZ44N.
I wrote a quick test program

void setup() {
  pinMode(6, OUTPUT);  // Red
  pinMode(3, OUTPUT);  // Green
  pinMode(9, OUTPUT);  // Blue

  digitalWrite(6, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(9, HIGH);
}
void loop() {
  // Turn on red
  digitalWrite(6, LOW); // Red ON
  digitalWrite(3, HIGH); // Green OFF
  digitalWrite(9, HIGH); // Blue OFF
  delay(1000);

  // Turn on green
  digitalWrite(6, HIGH);
  digitalWrite(3, LOW); // Green ON
  digitalWrite(9, HIGH);
  delay(1000);

  // Turn on blue
  digitalWrite(6, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(3, LOW); // Blue ON
  delay(1000);
}

When I connect R pad of the strip to drain of the corresponding mosfets it works. You see led strip being red 1/3 of the time and being 0ff for 2/3 of the time.
Same when I connect just Blue pad or Green Pad.
If I connect R and G or any other pair of colors it also works ok. But if I connect all three then I see weird colors. I think this is an issue with the type of mosfet I am using but it seem weird as I am not using PWM signal. I am providing either low or high signal at the gate so why would I get a pinkish color of the led strip. Can someone explain this phenomenon to me

You don't tell anything about the resistors you use for LEDs.

Well it is an led strip so the resistors are part of the strip. I connect gate to arduino pin via 220Ohm resistor and the gate to gnd via 10k

Ahh sorry for that. So how big is the strip? How is your power supply?

The way you have your gate and pulldown resistors connected they are forming a voltage divider. Try putting the pulldown on the other end of the gate resistor.

This mosfet is N-Channel Power MOSFET , and N types conducts when there is +v at the gate.
Therefore it will turn on the LEDs when the pin is High.

So, red 2/3 of the time On and being 0ff for 1/3 of the time.

Ref:

Can you explain? Do you mean to have the connection between the arduino pin and 220Ohm resistor to ground through 10k resistor?

The strip is common anode so I light the channal by applying the low signal at the gate. The mosfet connection is fine as it works as expected when I have just one or two color channels connected. The funny colors start when I have all three color channels connected. So it seam that then Arduino starts sending slightly different signals to the gate and the mosfets start working differerntly. Today I used the same exterlal power suply to malso power arduino. Tomorrow I will try to connect it just to led strip and power arduino fro USB , not sure if that would make any difference.
Also I was wondering if the selection of MOSFET matters. Would a different type of mosfets behave differently in this setup as it is better equipped to work with small voltages.

The 10k pull down resistor is there for the Arduino pin, not for the gate of the fet.
It keeps the Arduino pin LOW during bootup.
Only logic level mosfets should be used.
That excludes the common/cheap IRF520 etc.
Leo..

Not according to material you have posted.

My diagram shows the common anode strip. My code is also for the common anode. Which part of my description hinted common cathode strip?

But can you explain my problems appear only when all three mosfets are connected.

Does the 5volt LED supply come from the Arduino?
Too much current draw could drop that 5volt rail to the point that the fets don't function any more.

  digitalWrite(6, LOW); // Red **off**
  digitalWrite(3, HIGH); // Green **on**

Leo..

I had an external power supply 5v with 2A. I am currently powering a strip with just 6RGB leds so 18 leds . This should be 18x20ma so 360mA. SO this should be enough to power those leds and power arduino through 5V arduino pin

An addressable LED strip is so much easier...
Leo..

I know. But I am trying to make this RGB setup work. This setup on paper should work and I am trying to understand why it does not when 3 mosfet are created. The mosfet connectivity in my diagram is correct as it works when Just one mosfet is used

Show us the actual build (breadboard?).
Maybe the fets are oscillating. Try higher and lower value gate series resistors (100 ohm, 1k).
Leo..

Nothing did. But you wrote you light it driving the gate low and that doesn't match with your mosfet.
You didn't answer anything about the power source...

1 Like

Incorrect for N-channel MOSFETs.

  digitalWrite(6, HIGH); // Red ON
  digitalWrite(3, LOW); // Green OFF
  digitalWrite(9, LOW); // Blue OFF

Correct for N-channel MOSFETs.

1 Like

So how should this circuit look like for common anode strip. Again let me emphasize . The way the mosfets are connected works ok when I connect one color or even two colors. So how does it work when it is incorrect?