-1Locked. There are disputes about this answer’s content being resolved at this time. It is not currently accepting new interactions.
Question
How to use Arduino to control 3W RGB LED lamps?
Answer
Update 2021jan22hkt2201
BAD NEWS!!!
As pointed out earlier by @K H, the I-V characteristics of different colours of LED are very different (in turning points and non-linearity, etc), at shown below.
So it would be difficult to balance the brightness. @K H suggests using different voltage sources, and PWM etc. I have not explored his ideas further. I am afraid now I need to search this forum for old posts on LED control to get more ideas.

Update 2021jan21hkt1700
Now I am setting a test rig for calibrating constant current source (LM334Z) controlled blue LED. The starting point to calibrate is 2.5V 1.3mA, when Blue LED is just bright enough for my eyes. At 3V, 100mA, it is dazzling and blinding my eyes.
For this low current of 2mA, I am using 36Ω / 2 = 18Ω as the series register.

Part 3 – RGB LED Brightness Turning Point and 100mA Point Measuremeents
I found the dim to bright and bright to dazzling points (at 100mA) are very different for R, G, and B LEDs. So now I appreciate very much why it is efficient and reliable to use Constant Current Source to control the brightness of the RGB LEDs.
I have never used any Constant Current Source (CCS) in my projects. So I need to google a bit to see how to use it, … 🙂

Note: I found the multi-meter readings not very stable. I suspect the small hexagonal aluminium heat sink plates are not big enough at high power.
/ to continue, …
Part 2 – RGBYW LED I-V Measurements
1. Red LED V-I-B Test


- Blue LED Testa. 2.7V, 10mA Turning point, dim to pale brightb. 3.2V, 87mA Brightc. 3.3V, 102mA Very bright, but not dazzling
Part 1 – Preliminary Testing of RGB 1W LED lamps
I knew Cree’s 3W LED lamps would be too bright/dazzling for my eyes. So I decided to try the 1W LED’s first. I wired 4 single 1W LEDs, R, G, B, Y and use a button adjustable regulator to test the brightness.
I found the results very disappointing:
- Red and Yellow turns on at around 1.7V,
- Yellow only turns on at around 3V, and
- Blue only turns on later at around 3.3V.
At this voltage level of 3V3, other three RGY become very dazzling and I need to use a shade to soften/darken the lights, so not to blind my weak eyes.
I have too many photos to upload with the comments. So I am uploading them as part of my answer here.

References
(1) AliExpress YD-XGJH RGB/RGBW/RGBWY LEDs, 3W/9W/12W/15W, 2/4/6/8 pins – US$5 ~ US$110 (The 3W RGB LED the OP hopes to control by Arduino)
(4) P2N2222A Amplifier Transistors NPN Silicon – OnSemi
(5) ULN2003 Seven Darlington arrays Datasheet – ST
(6) ULN2803 ULN2803A Darlington Transistor Arrays Datasheet – TI
(7) LED Lamp 1W (3V ~ 3.5V, 300mA ~ 350mA) – DigiKey
(8) 1W High Power LED Datasheet – MultiComp
(9) Cree XLamp XHP70 LEDs Datasheet
(14) AliExpress LM334Z TO-92 three terminal adjustable constant current source IC – US$1.5/5pcs
(15) LM134/LM234/LM334 3-Terminal Adjustable Current Sources – TI
(16) LED Tutorial (Including power LED) – Nick Poole, Bboyho, SparkFun
(17) Constant Current LED Driver (FemtoBuck LED Driver) US$8 – SparkFun
Appendices
Appendix A – Testing 3 independent 350mA LEDs (recommended to newbies)

Appendix B – RGBYW 5 x 3W (Warning – Ninjas only)

Appendix C – AliExpress 1W 350mA LED Lamp Driver Module – US$1
Specification: Input voltage: DC 7 -30V Recommended input voltage: 24V DC Input filter: condenser Output voltage: 1.2-28V Output current: 350mA Output current accuracy: ± 3% Output current stability: Vin = 24V, Vo = 1.2-22V, ± 1% Internal power dissipation: Vin = 24V, 5 LEDS maximum 700mW Temperature coefficient: environmental protection temperature -40 ℃ -71 ℃, ± 0.015% / ℃ Full load efficiency: 96% Wave and noise (vp-p): Vin = 24V, 5LEDS, 120Mv Output short circuit protection: sustainable Package size: 25 * 15 * 10 (mm) without pin Weight: 4g
Use: In +: positive power supply Input: negative power supply. LED +: access the LED anode LED-: then the cathode LED PWM: dimming control signal (2.8V -6V open) PWM signal limit frequency: 20HZ -20KHZ nominal recommended: 1KHZ Buck operating mode to ensure that the full pressure of the LED below the input supply voltage 2 -3V works.
Package Included: Metal Melting Torch Mini Gold Furnace Graphite: 1 * DC in 7-30V 350mA LED Lamp Driver 1W Support PMW Dimmer
Appendix D – Newbie Cheat Sheet for RGB LED Circuit Design

ShareCiteEditFlagedited Jan 22 at 14:13answered Jan 19 at 9:06tlfong011,57411 gold badge66 silver badges1111 bronze badges
- Wow, sweet! Could you just add the schematics? Your answer is going to be my reference for while =D – GB5 Jan 19 at 11:38
- 1@tlfonf1: You’ve shown that it can be done, but not how. The how is the important bit, and belongs in the answer, not in some link. – JRE Jan 19 at 11:54
- 1The trick is not just in doing it, but in doing so safely and reliably. 3W is (comparatively) a lot of power. Just brutally PWMing the LEDs may “work” but burn them out in short order. You need to be sure that you won’t exceed the current limits for the LEDs. The LEDs may be able to withstand higher current for short periods – maybe the PWM pulses are short enough. Who knows. There’s no data on pulse current on the site, and no datasheet. – JRE Jan 19 at 12:01
- @JRE, Well, I agree. For now, I am just messing around, making mistakes, frying LEDs, and learn lessons. Now It is only Part 1. Part 2 is making measurements, basically V-I-P-B (Voltage-Current-PWM, Brightness) curve tracing/plotting, sort of writing spec/datasheet. Part 3 is basic circuit design, and of course schematics, …, Stay tuned, … 🙂 – tlfong01 Jan 19 at 13:41
- 1#GB5 and JRE, I am bearing in mind the rough voltage and current limit from the Op’s datasheet: For Red LED, voltage is 2.6V, current is 500mA. Part 2 measurement starts with Red LED. My firing budget is 5 damn cheap LEDs per day, … :), – tlfong01 Jan 19 at 13:55
- 1Very nice post. As you’ve been discovering, RGB LEDs require different voltage sources and also wattage levels in order to balance the colors and achieve “white” light. One option is to provide a source per voltage(preferably a current source), tune the output voltages to what you want to be “100% duty cycle” white light, and then achieve 0-100% dimming by using 0 to 100% duty cycle at that voltage. Testing LEDs with a voltage source is fine to learn their properties, but some form of current limit is necessary to prevent thermal runaway if the LED stays at 100% duty cycle and heats up. – K H Jan 20 at 2:12
- (1) Thank you very much for your nice words and very helpful and educational advice. Actually I have no experience at all in constant/adjustable current sources. I only know voltage regulators. One second thought, current source should be easier to adjust brightness (not sure, because I have been too lazy to google current vs brightness characteristic. I agree we might need to use three separate voltage/current sources, each with PWM, to control three RGB LEDs. Yes, this Q&A should be a good learning experience for all power RGB LED newbies. / to continue, … – tlfong01 Jan 20 at 7:11
- So we need to consider some form of current protection, to prevent what you say “thermal runaway” (I don’t know what it it, perhaps sort of nuclear power plant melting down, blacking out, causing red, green, and blue smokes/fires, and afterwards, all newbies weeping in the dark. 🙂 – tlfong01 Jan 20 at 7:13
- (2) But I am not keen at all to create white LEDs, because there are ready assembled CHEAP white LEDs from AliExpress. what I want is to combine 12-bit resolution RGB signals to create 65,536 different colours. – tlfong01 Jan 20 at 7:17
- @GB5, so I am going to design some simple circuits to control RGB LEDS, using 2N2222 first, and then ULN2803, TPI120, and IRL540N later. I should be using 16 channel PWM controller PCA9685 for my Rpi4B. BTW do your have any experience in using 2N2222 any PWM, Arduino or otherwise? Or you need to google very hard! 🙂 – tlfong01 Jan 20 at 7:26
- @tlfong01xD , with Arduino I feel comfortable, about the rest,I used it briefly in University, but its been a while….so I would have to say no experience and yes to google hard! Anyway, after your initial feedback I searched more and saw a few projects that used the ULN2003 and the TIP122 so I bought them from local stores (I have some time limit on this project, and AliExpress normally takes up to 1 month to arrive, so i’m counting on using the links you provided later to do similar projects =) ) – GB5 Jan 20 at 9:02
- @K H, Just now I googled what you advised, using current source, which is more preferred, and found the following good article, explaining why current source is better: LED Lamp 1W (3V ~ 3.5V, 300mA ~ 350mA) – DigiKey components101.com/diodes/1-watt-led. This newbie friendly tutorial says the following: “… For doing it we need to provide the CONSTANT CURRENT SOURCE or feedback system for the LED.”Many thanks for your help. Cheers. – tlfong01 Jan 20 at 10:45
- @GB5, I would suggest you to read Refs 7~9, to get a rough idea of what #JRE suggests, What, Why, and How” I am doing what I am doing. In Ref 7, You can also find a schematic of the basic wiring, just a 5V PSU and a series resistor (3Ω ~ 10Ω, high W), do you have those in hand, or could buy from local stores?) – tlfong01 Jan 20 at 10:57
- 1I’ve waited to see if you actually post a circuit or other practical tips on driving the LED. So far, it appears to be a blog post and a shopping list with nothing to actually suggest how to drive the LEDs. – JRE Jan 20 at 13:17
- 1Ah, @JRE has already made a complete, well documented circuit, using MOSFET. He also gives a newbie friendly, detailed instructions on how to calculate the series resistor, and also an example demo Arduino code. So you should for sure meet your project deadline. I will now go slow and see if I can make a similar circuit, using Rpi4B and NPN BJT 2N2222. – tlfong01 Jan 20 at 14:09
- 1I appreciate that you are trying to work out all the details on your own. I often make personal projects out of questions here on the EE Stackexchange in order to come up with a good answer. I work them out offline, though, then post the results and explanations when I’m done. This “answer” is a long list of all the parts you’ve collected to do your experiments and some partial results. In all honesty, it reads more like a shopping list or advertisement for Aliexpress than an explanation of how to build a circuit. – JRE Jan 21 at 9:32
- This kind of iterative approach is a good thing for learning for yourself, but not such a good thing as an answer. Stackexchange isn’t a blog. It is for providing answers. Some background to the explanation in an answer is (usually) a welcome thing, but you need to provide an answer as well as the background. I write a blog about the things I build and do in my free time. You might want to consider starting your own blog for this kind of thing. Maybe sign up on Hackaday.io and write your project notes there. – JRE Jan 21 at 9:42
Comments disabled on deleted / locked posts / reviews
.END
Categories: Uncategorized