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.
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI'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.
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:
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);
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 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:
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