Pharylon
Posts: 4
Joined: Mon Dec 19, 2016 1:52 pm

Chaining Simple RGB LEDs

Mon Dec 19, 2016 2:00 pm

I've done some simple blinking a led sort of stuff with the Rasbperry Pi, but I want to take it up a notch and maybe make something useful. I was toying with the idea of making a simple RGB "mood lamp." with the pi and some rgb leds in a frosted glass vase that I coudl control what color they glow, but reading up on RGB LEDs, I've gotten really overwhelmed with the the complexity jump. Plus, most guides I find are for individually addressable strips, and I don't really need/want that. I want LEDs that are RGB, but all glow the same color.

So after some more googling and more feeling overwhelmed, I came back to this simple instructable on lighting up a single RGB LED http://www.instructables.com/id/Using-a ... n-RGB-LED/ and I started thinking, could I just chain ten or so of these together and light them all up at once with the same color scheme? Seems like it would work in principle, but I don't know if the Pi is going to have any power issues to deliver enough juice to do that.

Anyone have any advice/pointers?

User avatar
Burngate
Posts: 6313
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Chaining Simple RGB LEDs

Mon Dec 19, 2016 6:41 pm

Pharylon wrote:... but I don't know if the Pi is going to have any power issues to deliver enough juice to do that.
That's going to be the potential problem.

A RGB led is just three leds in the same package, so driving one of those is only three times as complicated as driving one - three different GPIOs, one for each colour.

But each GPIO is limited as to how much current it can supply, so how many leds it can drive.
If you're willing to have them dimmer, you could use a higher-value resistor for each led, so you could drive more leds, but ...

So you'll need something to separate the signal (from the Pi) from the power (that provides the current your leds will consume)
Transistors, either FET or bipolar, would be useful here, and you can experiment with one in your "simple blinking a led sort of stuff" set-up, or three of them in your RGB instructable.

Then the good news is that, with the right transistors, you can chain as many as you like (each with its own resistor).
The bad news, of course, is that having done that, you won't be satisfied - you'll want more. There's Christmas gone, and New Year, and January, February ...

Pharylon
Posts: 4
Joined: Mon Dec 19, 2016 1:52 pm

Re: Chaining Simple RGB LEDs

Mon Dec 19, 2016 7:27 pm

Why do I need separate resistors? Couldn't I just have the legs of each LED all on the same circuit (ie, all the reds together, all the greens, etc) so controlling sending a light to one GPIO lights all the LEDs?

User avatar
Burngate
Posts: 6313
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Chaining Simple RGB LEDs

Tue Dec 20, 2016 10:49 am

An LED isn't linear, in that increasing the voltage across it doesn't increase the current through it in the same proportion - or put the other way round, increasing the current through it doesn't increase the voltage across it in the same proportion.
Futher more, not all LEDs are created equal even in the same batch.
So if you did as suggested, you could have one hogging all the current and glowing brightly, and the rest so dim you couldn't see them.

It's an experiment worth doing.
Choose a resistor that isn't too small, so that even if all the current flows through just one it won't burn out, and also won't overload the source.

Most LEDs seem to be spec'd at 20mA, but the Pi's GPIOs shouldn't be asked to supply more than about 10mA.
Also, LEDs need about 1.5v - green ones need more than red, and blue even more (it's to do with the energy of the photons) - so, if you're going to drive them from the Pi's GPIO, which gives 3.3v, the resistor will have about (3.3 - 1.5 =) 1.8v across it. Ohm's law: R = V / I so 180Ω

PiGraham
Posts: 3971
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Chaining Simple RGB LEDs

Tue Dec 20, 2016 11:12 am

You can buy strips of RGB LEDs as a cheap easy way to wire up lots of lights. Typically they have power and R,G and B control lines. You could rive those lines with simple drive circuits and use soft-PWM on the Pi to control the intensities of each component colour. The drive circuit could just be three transistors and a few resistors. Resistors for each LED will be built into the strip. You can cut the strip to any length at 3 or 4 LED boundaries.

Incidentally if you buy such a strip (~£10) it will probably come with a little control box and IR remote control to select colour and patterns. You don't have to use that, but it would be enough for a simple mood lamp.

Power for such a strip is commonly 12V and a PSU will be supplied.

Connect three Pi GPIO outputs each to the base of a transistor via a 100R resistor. Connect all emitters to GND and each collector to one of the RGB control lines on the strip.

Your transistors should be rated for several times the current that flows to ground on the control lines if you short them to GND. Ask the seller or measure it yourself (or both).
For reference look at any examples of drive circuits for high power LEDs or motors.

The common ULN2003A or ULN2803A seven/eight channel darlington driver chip often supplied with cheap stepper motors would probably do. That handles 500mA per channel which is probably enough. You can buy modules with these chips on for ~£2. They are very easy to use. Connect the inputs direct to GPIOs. It's something I've been meaning to try for a while.
Last edited by PiGraham on Wed Dec 21, 2016 7:40 am, edited 1 time in total.

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Chaining Simple RGB LEDs

Tue Dec 20, 2016 1:44 pm

Pharylon wrote:Why do I need separate resistors? Couldn't I just have the legs of each LED all on the same circuit (ie, all the reds together, all the greens, etc) so controlling sending a light to one GPIO lights all the LEDs?
yes you could drive all the LEDs from one output but you would need to add some other components between the GPIO and the LEDs. If it were me doing this I would use a ULN2803A which you can drive directly from the GPIO.
Image
you could replace the single LEDs shown in the digram with multiples
to work out your LED/resistor requirements you might want to look at this site http://led.linear1.org/led.wiz

for an example enter these values on the site 5v, 1.2v, 10ma, 15 select wiring diagram and hit the design button
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Burngate
Posts: 6313
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Chaining Simple RGB LEDs

Tue Dec 20, 2016 4:49 pm

pcmanbob wrote:... to work out your LED/resistor requirements you might want to look at this site http://led.linear1.org/led.wiz ...
The problem with that sort of site is that it doesn't explain how it reached its answer, or why it might be right.
Merlin did much the same sort of thing, invoking dragons and suchlike, and look where it got King Arthur.

As an example, I tried it with 12v for the source voltage, 2.0v for the LED forward voltage (its guess for red and orange LEDs), 10mA for the forward current, and 30 LEDs.
It recommended five chains of six LEDs in series with 1Ω resistors in each chain.

Let's assume our figures for the voltages are 100% accurate.
Then, in each chain, the six LEDs each have 2.0000v across them, so 12.000v total, so with 12.000v supply, there's 0.000v across the 1Ω resistor so 0.000A through it.
No current (instead of 10mA) means no light. The Wizard dropped a clanger.

Worse, if each of the LEDs only needs 1.9v (that's a 5% error) then there'll be 0.6v across the resistor, so there'll be 600mA through the LEDs - briefly, until one of them dies.

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Chaining Simple RGB LEDs

Tue Dec 20, 2016 11:16 pm

Burngate wrote:
pcmanbob wrote:... to work out your LED/resistor requirements you might want to look at this site http://led.linear1.org/led.wiz ...
The problem with that sort of site is that it doesn't explain how it reached its answer, or why it might be right.
Merlin did much the same sort of thing, invoking dragons and suchlike, and look where it got King Arthur.

As an example, I tried it with 12v for the source voltage, 2.0v for the LED forward voltage (its guess for red and orange LEDs), 10mA for the forward current, and 30 LEDs.
It recommended five chains of six LEDs in series with 1Ω resistors in each chain.

Let's assume our figures for the voltages are 100% accurate.
Then, in each chain, the six LEDs each have 2.0000v across them, so 12.000v total, so with 12.000v supply, there's 0.000v across the 1Ω resistor so 0.000A through it.
No current (instead of 10mA) means no light. The Wizard dropped a clanger.

Worse, if each of the LEDs only needs 1.9v (that's a 5% error) then there'll be 0.6v across the resistor, so there'll be 600mA through the LEDs - briefly, until one of them dies.

I never claimed the site was perfect you should always check by experimentation because components always have a tolerance.
but just for clarity this site explains how to calculate the resistances for yourself http://www.petervis.com/electronics/led ... lator.html should you not know how.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Burngate
Posts: 6313
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Chaining Simple RGB LEDs

Wed Dec 21, 2016 11:24 am

Sorry for the Grump. Happens now and then as one gets older - one expects the world to get better as time goes on, and the disappointment occasionally induces Grumps.

The sequence ought to be (1) cookery site, as in what do I do (2) experiment, as in what happens if I do that (3) theory, as in what is going on, so I can invent my own dishes
The internet is full of stage one sites, but no links from them to stage three.

jbudd
Posts: 1446
Joined: Mon Dec 16, 2013 10:23 am

Re: Chaining Simple RGB LEDs

Wed Dec 21, 2016 3:01 pm

I was toying with the idea of making a simple RGB "mood lamp." with the pi and some rgb leds in a frosted glass vase that I coudl control what color they glow
How about a Blinkt! (8 RGB LEDs in a row) or a Unicorn Hat (64 RGB LEDs in an 8 x 8 square)?
They are individually addressable so you can have them all the same colour or different.
They each plug in to the GPIO header and can be very bright. I don't know how they manage that, maybe they take power from the 5V pin?
There are Python libraries and example programs available.

Return to “Beginners”