I hate asking advice somewhere that I can contribute little so trust when I say that I have logged many, many hours researching this.. have watched every relevant video on YouTube I can find, every Reddit page and thread here I can find on the topic, and spent many hours prototyping in circuit simulators.. I will not list what all I have tried so far up to my current design because it's a lot. I am going CRAZY with this.. but GOOD NEWS, EVERYONE, I am getting close to figuring it out. It seems the common anode RGB LEDs are tougher than 6 pin or common cathode. I have been trying to figure out how to light up and control the color of a single 3W RGB LED for nearly a MONTH now. I just need a few pointers. I am very new to DIY electronics projects but eager to learn, and I'm hoping this thread may help someone else out in the future.

The goal:

  • Control the power, color and brightness of the LEDs using a Raspberry Pi Pico W and constant current supply

The priority:

  • COST and simplicity. I cannot find a premade circuit board for driving a common anode 3 W RGB LED via PWM anywhere, and any time I find something that seems like it might work, it's way too much $$$

  • Later I will figure out controlling it via Google Assistant, but that's not what I'm posting for.

I know there are IC's I can order for this purpose off DigiKey and the like, BUT I have already purchased a pack of logic level NPN FETs and LM317's hoping they would suffice and spent weeks trying to make them work. SO without ordering additional components I am hoping I can get at least one of these LEDs working as intended.

The current plan:
I've been testing using a 5 V source, an LM317 in CC configuration with a 3.6 Ω current limiting resistor between ADJ and OUT. I plan to use IRLZ34N "logic level" MOSFETs placed between the Pi Pico and LEDs, after the cathodes.


Here is the current design schematic. I apologize, I'm on mobile so I used the Proto app, which isn't great so I have to explain some of it since it's missing components I used:

3W Common Anode RGB LED Schematic

(Please ignore the overabundance of ammeters and unnecessary stuff I forgot to delete, and the weird grounding.)

The PROTO app does not have a common anode LED, the LM317 nor the IRLZ34N so I simply connected the anodes into one and drew three cathodes on the LED, and drew in names and values where pertinent. I did the best I could, let me know if there is anything confusing about it.

The problem currently:
I have only gotten so far in my testing as to set the current output of the LM317T with the 3.6 Ω resistor and connect the LED after it, so the above circuit without the mosfets.. and when I do, with a 5 V supply, THE LEDs WON'T ALL COME ON AT ONCE. For some reason, it will be red, or orange, but not white. It SHOULD be white if all 3 LEDs are getting power, right? If I connect each cathode one at a time separately, the correct color lights up, and when I connect red and green it will light up an orangish color, but connecting the blue in combination with either of the other cathodes does nothing to change the color. It seems that the red LED is the "preferred" path, and the blue LED is the last priority. I have tested continuity and resistance across all LED pins while disconnected from power and it seems the LED is not faulty.. I am at a loss. Am I missing something obvious, do I need resistors of different values placed after the individual cathode leads so that the current prefers all three paths equally? I was under the impression that with a constant current supply, the LEDs would pass however much forward voltage they "like" to pass and resistors are not necessary.. I also read in another thread that a 5 volt supply may not be enough in a circuit like this due to the total voltage drops of each component, so is it an issue of supply voltage? If anyone can solve this for me I will be eternally grateful.

I am literally just trying to light up a 3D printed Moon lamp I made for my daughter, and maybe add a single LED to my 3D printer for better visibility w/ webcam monitoring. In the future I will just order the best LED driver ICs I can find on DigiKey, even SMD components, idc. Anything to make this seemingly simple task ACTUALLY simple and affordable.. 🥲 also, it would just be good to actually be able to understand how this works and what the problem is. I would love to be able to DIY other "high power" LED lighting in the future, but this endeavor has been extremely frustrating.

Thank you SO MUCH in advance for your advice and for taking the time to read.

  • 2
    \$\begingroup\$ You need either three constant current regulators, one for each color or constant voltage + resistor for each color. \$\endgroup\$
    – winny
    Commented Jun 8, 2023 at 8:52
  • 1
    \$\begingroup\$ LM317 will not work in that case as current stabilazor properly, because it needs 2V voltage to work plus 1.25V drop voltage on resistor. Blue LED needs 3V to work. If you use constant voltage course, just resistor will be enough to set the current. And the best way to control brightness is PWM. \$\endgroup\$
    – user263983
    Commented Jun 8, 2023 at 10:18
  • 1
    \$\begingroup\$ A constant current source tries to keep the brightness of an LED constant, but you're designing a circuit that tries to adjust current using transistors which is the opposite of what the current source wants to do. You should reconsider using a current source for this circuit. \$\endgroup\$ Commented Jun 8, 2023 at 12:25
  • \$\begingroup\$ Your RGB LED is upside down. You have all three cathodes connected to positive and all three transistors connected to the anode instead of to the individual cathodes. \$\endgroup\$
    – Transistor
    Commented Jun 8, 2023 at 20:34
  • \$\begingroup\$ Hi! Thank you all for your responses. @winny regarding the first solution you suggest, as this is (unless I have my definitions backwards) a common anode LED, I wasn't sure I could use three separate power sources because there's only one positive input and three negative outputs. Is there some way to limit the current by placing PM317 after the LED in the circuit? (Ie: power source > LED+ > LM317 > GND)? I'm ignorant and assumed it needed to be placed before the LED+ \$\endgroup\$
    – Outbak Jak
    Commented Jun 9, 2023 at 23:19

4 Answers 4


It is not going to work quite this way.

The diode with the lowest forward voltage (red<green<blue) will hog the lion's share of the current when you try to operate more than a single one at once.

As the current control is dissipative, anyway, just drive the transistors into saturation and control each diode's current with a separate resistor according to \$(5 \text{V} - V_f - V_{sat})/I_f\$.

  • \$\begingroup\$ Wow, this is very helpful! When I am home next I will see what I can do to fix this circuit and report back. I was suspicious this may be the issue but I need to better understand how the power moves in a CC circuit, and just.. Electrical theory in general, much better. I'm trying though. I appreciate the reply \$\endgroup\$
    – Outbak Jak
    Commented Jun 9, 2023 at 23:48

You have all the LEDs sharing a single current limit resistor, and that will not work as you have seen.

As blue LED requires more voltage than red LED, and if you try to turn both LEDs on they will be in parallel and only red LED will be on because it limits the voltage and blue LED won't light up as there is not enough voltage.


What you do to drive this LED is connect the anode to +5V. Put appropriate resistors in series with each cathode, and then control the bottom end of the resistor with your MOSFETs. control the MOSFETs with PWM from the pi pico.

You'll also need to add a heastink to that LED. and you'll need at least 1W resistors for this task.

Don't stress over efficiency. for LEDs where brightness if directly proportional to current PWM is no more efficient than just using a resistor, and neither is the LM317.


If you want to work with the components you already have, it will help to put a resistor in each MOSFET source path. This creates a (more or less) constant current source for each individual LED. Skip the regulator in the anode path.

The value of the resistor depends on the MOSFET characteristic and needs experimental verification. There will be a thermal dependency: If the FET is hot the current will change significantly.

This solution may be good enough for a hobby project, but the variation in the threshold voltage between individual MOSFETs risks LED damage if currents close to the limit are configured.

The MOSFETs will dissipate heat because they are used in the analog region as variable resistors. This is a big difference compared to your original circuit.


simulate this circuit – Schematic created using CircuitLab


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.