Control a 3W RGB LED with an Arduino
Ask QuestionAsked 3 days agoActive todayViewed 149 times0
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.arduinoledShareEditFollowFlagedited yesterdayJRE44.5k88 gold badges7373 silver badges123123 bronze badgesasked Jan 17 at 23:52GB54155 bronze badges
- 2I think this question can be answered with a quick google search. – Damien Jan 18 at 0:43
- 3I’m voting to close this question because it lacks of research – Damien Jan 18 at 0:44
- 2You 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? – Tony Stewart Sunnyskyguy EE75 Jan 18 at 1:11
- 2You need 3 switches, controlled by arduino. Best choise MOSFETs. – user263983 Jan 18 at 2:27
- 1Your 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. – tlfong01 2 days ago
- (1) I suggest low voltage (3V) and low power (1W), low current (350mA) because for higher power, 6V/12, 3~5A power LEDs you need 5V/12V power MOSFET PWM switches. (2) I suggest 6 pin, instead of 4 pin (fixed common Cathode/Anode) modules, because you have more flexibility in circuit design. (3) For playing with power LED PWM, I suggest to try the following cheapy (US$0.9) PWM module: AliEXpress Diymore LED Lamp Driver PWM Dimmer DC7-30V to DC1.2-28V 350mA 1W DC-DC Converter Buck Step Down Module / to continue, … – tlfong01 2 days ago
- es.aliexpress.com/item/… Have a great power LED lamp project. Good luck. Cheers. – tlfong01 2 days ago
- I forgot two more things. (1) For preliminary testing, you don’t need to use Arduino. You can use the following handy testing tool to get the Voltage/Current/Brightness charteristics: AliEXpres Diymore-DC-DC Step-Down Button Adjustable Power Supply Module with LCD Display DC5-23V to DC0-16.5V 3A US$ 2.84: / to continue, … – tlfong01 2 days ago
- es.aliexpress.com/item/…. – tlfong01 2 days ago
- If you later want to do precise PWM LED control, you can consider this cheapy US$2 goody: XY-LPWM 1Hz-150Khz, PWM Pulse Frequency Cycle Adjustable Signal Generator Module 3.3V-30V LCD Display US$1.72 es.aliexpress.com/item/…. Cheers. – tlfong01 2 days ago
- 1TonyStewartSunnyskyguyEE75 That (Electronics is not my beach) and also the fact that I don’t really understand where for instance I would connect the signal data port from arduino to the led (according to the description one is the positive,which I assume cant be the signal port and everything else is ground?) and on my search i didnt found any project using rgb 3w with 4 pins explaining it. @tlfong01 thanks! I’m going to look through the material you recommended and see if i can come up with something. – GB5 2 days ago
- @GB5, You are welcome. For newbies, I would recommend to start with just one single 350 mA LED, instead of all three R, G, B together. When you are going well, then you can of course do more LEDs, even 5!: i.imgur.com/eCLayJx.jpg. PS – to drive a 350mA load you need a transistor to help. eg Arduino drives 2N2222 (Ic 800mA max), which in turn drives one or two LED. Or you need more more powerful drivers to entertain more LEDs.. – tlfong01 2 days ago
- @GB5, I must first confess that I have very little experience with power LED lamps. So my suggestions here might be simply wrong or misleading. Anyway, I am going to explore using my poorman’s cheapy tools. I will be writing some research reports now and then. It it only after I have some confidence that I am not doing stupid things, then I would consider writing an answer to you question, mainly for power LED newbies. Now I heard that Cree’s power LED is the best brand. So I googled to know more, like why there is an aluminium back plate and how to do the soldering. / to continue, … – tlfong01 2 days ago
- I am studying the Cree’s 5 x 3W models, before experimenting a single 1W model. 5x3W Cree XPE XP-E High Power LED Emitting Diode, Neutral White Cool White Warm White Red Green Blue Yellow with PCB – US$4.5/5 pcs es.aliexpress.com/item/… – tlfong01 2 days ago
- 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 LEDs, R,G,B,Y and use the button adjustable regulator to test the brightness. I found the results very disappointing: (1) Red and Yellow turns on at around 1.7V, Yellow turns on above 3V, and Blue only turns on at around 3.3V. At this voltage, other three RGY become very dazzling and I need to use a shade, so not too blind my eyes. I have too many photos to upload in the comments here. So I am uploading them as part of my answer. – tlfong01 yesterday
- 1The web link is not “very good.” It is in fact “very bad.” It includes information on unrelated parts, and has very little in the way of concrete data about any of them. – JRE 18 hours ago
- 1@GB5: The LEDs you are looking at don’t have a “signal port.” They are simple, stupid LEDs that require you to switch power to the individual LEDs in the housing. They have a + pin for all LEDs, and a – pin for each individual LED. Connect the + to a power supply, connect the – for one color to ground (through a resistor) to make it light up. – JRE 17 hours ago
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=Vsupply−VfImaximumR=Vsupply−VfImaximum
Assuming a power supply of 5V, and a maximum current of 300 milliamperes, you get the following resistors:
|Color||VfVf||Resistor (ohms)||R (Adjusted for brightness)|
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=Vsupply−VfR×(Vsupply−Vf)=0.6watts.P=Vsupply−VfR×(Vsupply−Vf)=0.6watts. 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);
analogWrite(PWM_Red,0); analogWrite(PWM_Green,0); analogWrite(PWM_Blue,0);
analogWrite(PWM_Red,0); analogWrite(PWM_Green,0); analogWrite(PWM_Blue,255);
ShareEditFollowFlagedited 14 hours agoanswered 16 hours agoJRE44.5k88 gold badges7373 silver badges123123 bronze badges
- 1thanks! 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 14 hours ago
- 1awesome, 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 5 hours ago
How to use Arduino to control 3W RGB LED lamps?
Part 3 – RGB LED Brightness Turning Point and 100mA Point Measuremeents
I the dim to bright and bright ti dazzling points (at 100mA) are very different for R, G, and B LEDS. So now appreciate very much why it is efficient to use Constant Current Source to control the brightness of the RGB LEDs.
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.
(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)
(2) AliExpress Chanzon – Aluminum Heatsink Base Plate 1W, 3W, 5W LED PCB Board, 20mm Heatsink Substrate, 20mm Star Kit, for 1, 3, 5W – US$1.56-2.59
(3) AliExpress 5x3W Cree XPE XP-E High Power LED Emitting Diode, Neutral White Cool White Warm White Red Green Blue Yellow with PCB – US$4.5/5 pcs
(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
(10) 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
(11) AliEXpres Diymore-DC-DC Step-Down Button Adjustable Power Supply Module with LCD Display DC5-23V to DC0-16.5V 3A US$ 2.84
(12) AliExpress XY-LPWM 1Hz-150Khz, PWM Pulse Frequency Cycle Adjustable Signal Generator Module 3.3V-30V LCD Display US$1.72
(13) AliExpress Chanzon Aluminum Heatsink Base Plate 1W/3W/5W LED PCB Board, 20mm Heatsink Substrate, 20mm Start Kit -US$1.56-2.59
(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
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
ShareEditDeleteFlagedited 2 mins agoanswered yesterdaytlfong011,35211 gold badge55 silver badges99 bronze badges
- Wow, sweet! Could you just add the schematics? Your answer is going to be my reference for while =D – GB5 yesterday
- 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 yesterday
- 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 yesterday
- @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 yesterday
- 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 yesterday
- 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 yesterday
- (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 21 hours ago
- 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 21 hours ago
- (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 21 hours ago
- @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 21 hours ago
- @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 19 hours ago
- @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 18 hours ago
- @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 17 hours ago
- 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 15 hours ago
- 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 14 hours ago
Leave a Reply