Go Down

Topic: 10 RGB leds - all doing the same (Read 4972 times) previous topic - next topic

Justniv

Hi everyone :)
I've been looking for a topic similar to mine but did not find any'so im posting this one.
I want to light up 10~ RGB leds, all of them doing the same - for now just fading between colors, and after that controlling the color with potentiometer.
So about controlling the color i dont think the arduino will have a problem - all leds connected  in parallel to pins 8,9,10 (for example). The power supply should be the problem. I should mention that im newbie to electronics&arduino , and this is my first project, i'll be happy to get some guidness - like:
- do i need anything else than arduino&external power supply?
- how much should be the external power supply?
- should i connect all the leds in parallel ? or devide it to 3in a rowx3in parallel
Thanks :)

johnwasser

It would help to know the Forward Voltage for each of the colors, the current requirement of each color,  and if the RGB LEDs have a Common Anode or Common Cathode.

Because of the Common you can't put the LED's in series.  You can't put them directly in parallel because some will draw more current than others and might overload.

The cheapest way to drive them is to put a current limiting resistor in series with EACH and put a small NPN transistor between the LED Cathode and Ground.  This works fine if your LEDs are Common Anode.  If you got Common Cathode LEDs you will need to use a 5V supply and a PNP transistor between +5V and the Anodes.  You will find the PWM inverted: the light will turn off at 255 and on at 0.

30 (10x3) LEDs drawing probably around 20 mA each will require a 600 mA power supply.  Add 100 mA if you want to run the Arduino off the same power.  You can either use a regulated 5V supply or an unregulated 7-12V supply an get 5V 600 mA from the Arduino's regulator.  Note: If you power the Arduino from USB it only has about 400 mA to spare so you WILL need an external supply.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Justniv

I didnt bought the leds yet, so its not a problem. i just dont know the forward oltage (and whats its means), what should i get a common cathode or anode?
Can you explain me why do i need transistors? as far as i know they function as a buuton - but not physically' you "press" it with and electric pulse, so why do i need many transistors?

Quote
30 (10x3) LEDs drawing probably around 20 mA each will require a 600 mA power supply

i only want 10 leds
thnx

johnwasser

> what should i get a common cathode or anode?

Since it is easier to use NPN transistors between Cathode and Ground you want Common Anode.  That way you can separate the Red, Green, and Blue Cathodes and use one transistor per color.

> Can you explain me why do i need transistors?

Arduino pins can supply AT MOST 40 mA.  Each of your color channels will draw about 200 mA.  The transistor allows a small current from the Arduino (< 40 mA) to switch a large current from the power supply (~200 mA).

> I only want 10 leds.
Yes.  10 RGB LEDs.  Inside those are 10 Red, 10 Green, and 10 Blue.  That makes 30.  Just because they are in a single package doesn't mean they don't each require about 20 mA.  If you want to think of them as single units then each one will draw about 60 mA. 60 * 10 = 600 mA.  Same answer either way.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Justniv

ok, i read you reply like 10 times - im starting to get the idea you meant.
1. is that mean that i need 30 NPN transistors...?  :smiley-eek:
2. i didnt understand how to connect the NPN to the arduino pin AND to an external battery so after a bit of searching i found this sketch- (led strip), and i do understand it - BUT it's not with an external power
thnx :)

Chagrin

It is with external power. The grey wire connecting to the "9V" pin (which should be labeled "Vin") is directly connected to the power jack and "unregulated" (not regulated by the Arduino which only regulates the 5V and 3.3V pins).

Transistor tutorial; it's worth 10 minutes of your time: http://www.kpsec.freeuk.com/trancirc.htm


johnwasser

> 1. is that mean that i need 30 NPN transistors...?  :smiley-eek:

No, you need one transistor per GROUP of cathodes.  Since you have three groups of cathodes (reds, greens, and blues) you need three transistors, like in the LED strip example you found.  Each cathode will need a current limiting resistor.  That is EACH cathode so you will need 30 resistors.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

CrossRoads

Like this.
With an appropriate power supply
http://www.dipmicro.com/store/DCA-07510

Make yourself a splitter cable for the power
http://www.alltronics.com/cgi-bin/item/98J009/search/2.1mm-X-6mm-Coax-Power-Connector
http://www.alltronics.com/cgi-bin/item/23J013/search/5.5mm-x-2.1mm-Coax-Power-Connector
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Justniv

Thank you all,
Quote
It is with external power. The grey wire connecting to the "9V" pin

1.so for external power, is it gonna be ok to take this: http://www.dipmicro.com/img/1/DCA-FULLVIEW.jpg
cut his adapter-then i'll have two wires-so i'll connect one to "GND" pin and the other wire to "Vin" pin?
(im planing to do it with an old charger like nokia phone charger - but with the right properties)

2. The NPN, what do i need to know about it in the datasheet?
which one will fit the best:
http://www.taydaelectronics.com/2n3904-npn-general-propose-transistor.html
http://www.taydaelectronics.com/2sc945-c945-bipolar-transistors-npn-50v-0-15a.html
http://www.taydaelectronics.com/2n2222a-2n2222-npn-transistor-0-8a-40v-to-18.html
and whats are the purpose of each one, i mean whats the differences?

3. just out of curiosity, insted of putting a resistor in every led, can't i put "high" resistor at the emmiter of each NPN? i mean between GND and Collector&Base "junction".

again thnak u all i apriciate your help :)
CrossRoads special thank for the sketch pic


johnwasser


3. just out of curiosity, insted of putting a resistor in every led, can't i put "high" resistor at the emmiter of each NPN? i mean between GND and Collector&Base "junction".


No, you can't.  Ten LEDs draw ten times the current of one LED but if you put 10 LEDs in parallel and feed them ten times the current there is no way to make them share the current equally.  Some devices will hog the current, overheat, and die.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

CrossRoads

#1 - yes, basically make a Y cable with Power/Gnd at the end of the Y legs:

P------|------------------P
G____|___________G
      |  |----------------- P
      |______________G

#2 - each transistor needs to have
Continuous Collector Current:
of 10 * LED current (10 X 0.02A = 0.2A, 200mA)
The 2n2222 can do that.  The other2 can't.
Good to give yourself some margin there too - don't run parts right at the limit of what they can do.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Justniv

#11
Sep 17, 2012, 06:31 pm Last Edit: Sep 17, 2012, 06:33 pm by Justniv Reason: 1
1. i'm sorry crossroad but i dont understand what did u mean with this sketch-

P------|------------------P
G____|___________G
     |  |----------------- P
     |______________G

i meant to do exactly like this:




but, whats the max that i can put ? what should be max current/voltage of the adapter?
and do  i need to feed the arduino as well? or it "know" how to use the power from the "VIN" pin?


2. about the Continuous Collector Current, is it 20mA after the resistor?
what resistor should i use? i think the blue and green should be 220ohm, and the red 300ohm. (but what do i know :)  )
thnx



CrossRoads

The resistor will depend on the LED.
Red, generally are 2V.
Green, Blue, generally 3.3V.
The Transistor will have voltage drop from collector to emitter, ~0.7V
So do some math:
( (Vsource) - (Vce-transistor) - (Vf-led) ) / (current desired) = Resistance needed
(5V - 0.7 - 2)/0.02 = 115 ohm
(5V - 0.7 - 3.3)/0.02 = 50  ohm
Check the parts you want to use and put int the right values.

For the splitter cable - hard to draw graphically.  I can't open your attachments.
The arduino will draw what it needs, like 40-50mA.
The 30 LEDs will draw whatever you decide to let them draw via resistor selection.
30 LEDs, 20mA, so 600mA.
So use that to size your supply requirements.
The barrel jack connector output goes to a reverse polarity protection diode which then connects to the Vin header pin, and then feeds the 5V regulator and shows up at the 5V header pin.
If you want to use 7.5V to supply the barrel  jack, or the Vin pin, and the LEDs in parallel (adjusting your resistor values accordingly) that would be ideal.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Justniv

- how do you know the red is 2V and the green&blue are 3.3v? you own experience  or am i missing somthing?
-
Quote
(5V - 0.7 - 3.3)/0.02 = 50  ohm

and if for example im gonna use 100ohm - nothing bad will happen it's just gonna be a bit dimmer, and it's gonna have a longer life?


- about the supply: for the leds : 600mA, Arduino: 50mA  - that's mean i need a supplier of EXACTLY 5V/650mA ?
- about the connections - im not sure i understand you
Quote
The barrel jack connector output goes to a reverse polarity protection diode which then connects to the Vin header pin, and then feeds the 5V regulator and shows up at the 5V header pin


im sorry but what 5V regulator? im realy a newbie :\

i draw another one with the diode u said i hope u can see this one:
http://sphotos-g.ak.fbcdn.net/hphotos-ak-ash3/s720x720/550573_4395099432812_145428076_n.jpg

CrossRoads

Red/Green/Blue - approximate values from experience. Read your device's datasheet.
Higher will only make the LEDs dimmer and not damage anything.

Total current - your supply may be capable of 5V, and a gazillion mA- the circuit will only draw what is needed, limited by internal resistances, or LED current limit resistors.
http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf
Look at the top right - X1 is barrel connector, D1 is reverse polarity protection diode, U1 is the onboard regulator.
The voltage before the diode should be ~7.5V, the voltage after the diode ~6.5V, and the regulator will output 5V.

Connect your RGB LED anodes to Vin.
Make sure your walwart is >=7.5V (up to abiout 12V).  You don't need the external diode, but it does offer extra protection.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up