Pages: [1]   Go Down
Author Topic: How to control RBG LED with 1 output?  (Read 1212 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm curious how easy/difficult it would be to do something (I'm a novice with electronics and arduino), I'll do my best to explain.

I want to get 2 different colors out of my RGB LED, doesn't matter which colors, but I want to be able to do it with 1 PWM pin, instead of 1 pin per color.

PWM: 50 - Illuminate only blue led (using the full amount of power provided)
PWM: 150 - illuminate blue led with 1/3 the power, and the red led with the remainder.

Or if there's a better way to go about this, I'm all ears smiley  Thx
Logged

Offline Offline
Edison Member
*
Karma: 6
Posts: leet
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could do this by changing the frequency, and some caps, OR

If you design the matching circuit for red only, not blue, the red will ignore short pulses and only light when they get much longer.  In effect changing the color and the brightness together as you increase the duty cycle.  You just need to choose an appropriate time constant.  I will leave this as an exercise for the reader.

Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You could do this by changing the frequency, and some caps,
Yes.
But the problem is the peak current into the capacitors will exceed the maximum allowable current from the pin if you are not careful. Remember a discharged capacitor looks like a dead short when you put a logic high signal on it at first.

However changing the duty cycle will have no effect on a capacitor's reactance.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I did a little reading on the phases at the Arduino, and at the present time, way over my head.  Trying to think of an easy alternative, and had one idea..

I've got a relay module, and if I understand right, the coil activates at ~3v.  So, maybe it's possible to hook the relay up to just 1 color of the led, this way when the pwm output is at low power, the relay doesn't have enough power to trigger; but at full pwm power, the relay will trigger and both colors on the rgb led will fire, instead of 1.

Before I screw up something though, I should ask, would it be safe to try use the pwm for relay control in this way?

edit: guess that wont' work.. after looking more closely, the rgb led uses all negative leads for the colors, so I can't use the relay to control that, bummer.
« Last Edit: April 13, 2012, 12:21:01 am by corpse » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes that would work although you have to drive a relay through a transistor.

Quote
rgb led uses all negative leads for the colors
No problem, just connect the anode to +5V, the red cathode through a resistor to the PWM pin. Then connect the relay contacts to the green cathode via a resistor and the other contact to ground.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes that would work although you have to drive a relay through a transistor.

This is the path I'm going down http://www.csgnetwork.com/transistorcalc.html
This is my first time looking/trying to understand this schematic.. I entered values:
VCC=5
R1=100
R2=500

I presume the connections mean (and how I'd use them in my scenario):
VCC -  5v
VB - pin 9 PWM
VEE - GND
VC - first led
VE - second led

As VB increases, once it hits almost 1v is when ve starts to output power (ie: to my second led)

Is that kinda how that circuit works? 

If my understanding is more or less right, how do I know which transistor in this case to get when I head to radio shack?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is the path I'm going down http://www.csgnetwork.com/transistorcalc.html
That is not quite how you want to use it.
R2 should be zero ohms, that is it should not be in the circuit, replace it with a short.
R1 is your load, this is where the relay coil should go.
You need a resistor from the base to your arduino PWM output.

This will explain what PWM actually does.
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

This shows you how to wire up a relay:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html
Any general purpose NPN transistor will do, I am assuming your relay doesn't take current, less that 100mA anyway. If it is more you need a transistor that can handle the current your relay requests.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...would it be safe to try use the pwm for relay control in this way?

You'll want to use a capacitor to smooth out the voltage being applied to the relay coil.
Otherwise, the sharp edges of the pulses will cause all sorts of transients on that pin.
I wouldn't be surprised if it caused problems in other parts of the circuit as well.
Depending on the current requirements of the relay, you may not be able to supply it directly from the pin, and would likely need a transistor as well.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You'll want to use a capacitor to smooth out the voltage being applied to the relay coil.
Otherwise, the sharp edges of the pulses will cause all sorts of transients on that pin.
No you don't, no it won't.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You'll want to use a capacitor to smooth out the voltage being applied to the relay coil.
Otherwise, the sharp edges of the pulses will cause all sorts of transients on that pin.
No you don't, no it won't.

Mike,
  Are you saying that the rapid on-off of PWM on the relay coil won't cause inductive responses?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am saying it will not cause you trouble, there is no need to smooth it. The inductor has its own time constant, so current will not be switching as rapidly as you might think.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where things won't hurt, and may help, I generally prefer to do them unless there are extenuating circumstances.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31555
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Where things won't hurt, and may help, I generally prefer to do them
Yes but this will hurt and won't help.
The output dissipation of the driver will increase when it is operated in the linear region.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then it comes down to whether the extra heat in the transistor or the noise generated are worse.

Honestly, at low levels, neither is likely to be a problem.
Logged

Pages: [1]   Go Up
Jump to: