# Control a 3W RGB LED with an Arduino

I'm not sure how to do this. I have this LED - the 4 pin 3W RGB led.

I want to be able to control it using an Arduino (ideally I would control 4 - 6 LEDs.) By controlling I mean not only control the color but also turning it on and off.

• I think this question can be answered with a quick google search. Jan 18, 2021 at 0:43
• I’m voting to close this question because it lacks of research Jan 18, 2021 at 0:44
• You need a 350 mA PWM low side driver for 3 ch. and a large heat sink. What’s the problem? Choosing a 1V 15A FET? Jan 18, 2021 at 1:11
• You need 3 switches, controlled by arduino. Best choise MOSFETs. Jan 18, 2021 at 2:27
• Your web link is very good, because it shows a big variety of products, and also give detailed description of specifications of physical and electrical properties. For newbies, I would recommend to prototype with low power (1W per LED), and more pins (2 pin per LED). My suggestion is this one: 3W RGB 6 Pin 3V 350mA Power LED i.imgur.com/UgfFkHj.jpg. Jan 18, 2021 at 6:33

First off, note that the LEDs you have chosen have a pad on the back side:

That pad must be soldered, and it must go to a large metal surface on your circuit board. High power LEDs can get hot. The metal helps to radiate the heat away and keep the LEDs cool(er.)

If you don't do that, your LEDs will not live long at full power.

It is not clear if the thermal pad is connected to one of the other pins. Without a note in the "datasheet" (that web page hardly deserves the name) I would assume it isn't connected. If you already have them, check all the pins against the pad with an ohmmeter and see if the pad is connected to anything. It might be connected to the + pin.

As to driving the LEDs:

The simplest is to use a standard pulse width modulation circuit and a series resistor. That's probably not the best, but certainly the simplest to achieve with limited parts.

This is a simple circuit to drive one LED:

simulate this circuit – Schematic created using CircuitLab

PWM comes from your Arduino. That's a digital signal that switches on and off for a variable time. It comes from the misnamed Arduino "analogWrite" command.

You will need three of those for each 3 color LED you want to drive - one circuit for each color.

You have to calculate the resistor value from the maximum current you want to use, and the approximate forward voltage. You use the worst case forward voltage - that's the lower one.

$$R = \frac{V_{supply}-V_f} {I_{maximum}}$$

Assuming a power supply of 5V, and a maximum current of 300 milliamperes, you get the following resistors:

Color $$\V_f\$$ Resistor (ohms) R (Adjusted for brightness)
Red 2.0 10 26.7
Green 3.0 6.7 26.8
Blue 3.0 6.7 6.7

I've included an adjustment for the relative brightness (luminous flux as the datasheet calls it) to make the full on brightness of the LEDs come out somewhat close.

The full circuit for one LED would look like this:

simulate this circuit

The red and green LEDs won't get as much current as the blue one, but they should be somewhat closer in brightness due to the different resistors.

You'll have to pick resistors rated for the dissipated power. The resistor for blue will dissipate the most power. That's $$\ P =\frac {V_{supply}-V_f} {R} \times ({V_{supply}-V_f}) = 0.6 watts.\$$ You'll want to use resistors rated for at least 1 watt.

You drive each PWM pin with an analogWrite command. It will take three pins to control all three colors of one LED.

All on, fully bright, close to white:

analogWrite(PWM_Red,255);
analogWrite(PWM_Green,255);
analogWrite(PWM_Blue,255);


All off:

analogWrite(PWM_Red,0);
analogWrite(PWM_Green,0);
analogWrite(PWM_Blue,0);


Blue:

analogWrite(PWM_Red,0);
analogWrite(PWM_Green,0);
analogWrite(PWM_Blue,255);

• thanks! Mine don't have pad. But I bought a few so I could solder them and I also bought a couple 3w 6 pin LEDs (with the pad already). After work I'm going to read thoroughly your answer. Thanks!
– GB5
Jan 20, 2021 at 14:34
• awesome, following your instructions everything works perfectly! ibb.co/56BCWXz When I have the circuit more organized I will post the image here, the components and the code that I used, so it can become even more newbie friendly. Thanks!
– GB5
Jan 20, 2021 at 23:29
• @GB5: Thanks for the picture. It's nice to see what comes out of an answer.
– JRE
Jan 21, 2021 at 7:06

Question

How to use Arduino to control 3W RGB LED lamps?

Update 2021jan22hkt2201

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

1. Blue LED Test

a. 2.7V, 10mA Turning point, dim to pale bright

b. 3.2V, 87mA Bright

c. 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:

1. Red and Yellow turns on at around 1.7V,

2. Yellow only turns on at around 3V, and

3. 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.

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)

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

AliExpress Diymore LED Lamp Driver Support PWM Dimmer DC 7-30V to DC 1.2-28V 350mA 1W DC-DC Converter Buck Step Down Module

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

• @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, 2021 at 11:54
• The 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, 2021 at 12:01
• #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, ... :), Jan 19, 2021 at 13:55
• Very 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, 2021 at 2:12
• I'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, 2021 at 13:17