Pages: [1] 2   Go Down
Author Topic: multiple LED's in SERIES one output  (Read 2362 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello..complete NEWB here (took my first C++ class this past winter quarter and could see many similarities of coding in arduino). I used this tutorial to make an LED fade in and out ( http://arduino.cc/en/Tutorial/Fade ). I was able to get it to work but it doesn't work on multiple LED's that are in series. I was able to get it to work on LED's that were connected parallel but I would like to get it to work on an abundant amount of LED's in series.   Any advice or help would be greatly appreciated. Thanks!

This is the code that I am using :

/*
 Fade
 
 This example shows how to fade an LED on pin 9
 using the analogWrite() function.
 
 This example code is in the public domain.
 
 */
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

void setup()  {
  // declare pin 9 to be an output:
  pinMode(9, OUTPUT);
}

void loop()  {
  // set the brightness of pin 9:
  analogWrite(9, brightness);   

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }     
  // wait for 30 milliseconds to see the dimming effect   
  delay(30);                           
}
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26529
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was able to get it to work but it doesn't work on multiple LED's that are in series.
Describe "doesn't work".

Did you remember the voltage drop across series-connected LEDs adds up?

Quote
took my first C++ class this past winter quarter and could see many similarities of coding in arduino
Not surprising, because "arduino" is C++
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

Quote
I was able to get it to work but it doesn't work on multiple LED's that are in series.
Describe "doesn't work".

Did you remember the voltage drop across series-connected LEDs adds up?

Quote
took my first C++ class this past winter quarter and could see many similarities of coding in arduino
Not surprising, because "arduino" is C++

When I mean it doesn't work. The LED's does not light up at all. Yes I do remember that components such as LED's and resistors drop voltage when in series but When I connect at least 2 LED's in series it does not light up at all or very faintly (could be barely detected by naked eye).
Interesting that arduino is C++, was it literally based off C++? Sorry I am a total newb and still in my learning process (which I know will never end) but I just started messing around with electrical circuits not too long ago. Thanks for responding and helping.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26529
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Uhh, what value is the resistor?

Resistor value is (supply voltage - sum of Vf for all LEDs) / current.

So, if you've got two LEDs in series, each with a 2V drop and a 5V supply, to get 20mA through them, you need a 50 ohm resistor
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

ok thanks for the electrical 101 refresher. It makes sense cause i had a 250ish ohm resistor but I also tried it without the resistor and it still is REALLY faint (barely noticeable). Why would this be?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26529
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I also tried it without the resistor and it still is REALLY faint (barely noticeable). Why would this be?
Because you've burnt the pin out?

Never, never, never, connect a LED to an output pin without a resistor
Did I mention never?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

hahahahahahah damn. LESSON #1.

Quote
I also tried it without the resistor and it still is REALLY faint (barely noticeable). Why would this be?
Because you've burnt the pin out?

Never, never, never, connect a LED to an output pin without a resistor
Did I mention never?

so output #9 would be burnt out and would not be usable anymore?
I understand that a large amount of current is flowing because the resistor isn't there but
why is that when I connect a resistor back to #9, it is still able to be functional (the LED's in parallel are still fading in and out)?
« Last Edit: March 23, 2012, 04:21:45 am by eadizon » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26529
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I really don't know.
I don't have your hardware and I can't see what you can see.

There is really no reason that you couldn't put, say, two small red LEDs, each with a Vf of 1.8volts in series with an 82 ohm resistor and hang them both off one of the PWM pins, and see it fade up and down, assuming the AVR is powered from 5V.

(BTW, there's no need to set the pinMode of a PWM pin)

Quote
so output #9 would be burnt out and would not be usable anymore?
No, it may not be immediately obviously damaged, but could fail later.
« Last Edit: March 23, 2012, 04:30:56 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use transistor to drive the Multiple LED from a steady source of power (see the Attached Schematic).transistor can be BC558, 2n2222, BC 547, just care for the Base current needed to activate the Transistor, however the transistors listed above can easily be activated with the mA and voltage supplied from ATmega pins itself.


* LED_PWM.jpg (35.76 KB, 871x441 - viewed 71 times.)
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

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

Use transistor to drive the Multiple LED from a steady source of power (see the Attached Schematic).transistor can be BC558, 2n2222, BC 547, just care for the Base current needed to activate the Transistor, however the transistors listed above can easily be activated with the mA and voltage supplied from ATmega pins itself.

Wow..thanks for the schematics, it really helps with the visual aid. So I'm able to have free access to PN2222 at my ECE department at school. I read in wikipedia that the PN2222 is a replacement of the 2n2222.  (Replacements are commonly available now in the cheaper TO-92 packaging, where it is known as the PN2222 or P2N2222.) . So I'll definitely give your schematic a go next week. ALSO, will this schematic work with the code that was giving in the first post? Thanks!
« Last Edit: March 23, 2012, 04:57:17 am by eadizon » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26529
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The circuit will work with the code posted, but for safety, in case you change the value of fadeAmount, I'd change the comparisons for "<=" and ">="
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's a quick working pic for you ATTACHED, The single LED is there other other ones are to be similarly connected.



* DSC_0146.JPG (625.45 KB, 2592x1944 - viewed 66 times.)
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

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

Alright so I have a weird situation going on with the schematic. When I make all the connections according to the schematic and I plug in the arduino (already uploaded the code) nothing happens. When I take out one of the resistors and plug the LED in ( which I know that I'm not suppose to do according the post above) the LED lights up (fading in and out). The weird part of this is when I put a jumper wire in front of the LED with no resistor and it doesn't light up. For some reason the jumper wire is disabling the LED from lighting up? I have pictures. The first picture is of the schematic that was given in the previous post.  The second picture is when I take the one of the resistors in front of the LED out and the LED lights up. And the third picture is when I put a jumper wire in front of the LED and it DOES NOT light up. I thought that this was extremely odd. Any insights?


* IMG_20120330_152615.jpg (1071.71 KB, 1920x2560 - viewed 56 times.)

* IMG_20120330_152736.jpg (628.91 KB, 2560x1920 - viewed 30 times.)

* IMG_20120330_152807.jpg (640.22 KB, 2560x1920 - viewed 48 times.)
« Last Edit: March 30, 2012, 06:04:44 pm by eadizon » Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1619
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

STOP!

You are killing your Arduino , all the rails on the BreadBoard are electrically connected when you put your LED;s both leads and +ve and -ve leads both on the same rail AS YOU ARE DOING you are shorting the circuit by running the +ve and -ve current on the same rail.
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

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

STOP!

You are killing your Arduino , all the rails on the BreadBoard are electrically connected when you put your LED;s both leads and +ve and -ve leads both on the same rail AS YOU ARE DOING you are shorting the circuit by running the +ve and -ve current on the same rail.

SMH...lesson # 2...thanks. it's the lines that are horizontal that are connected together and the vertical lines are NOT connected. right?
Logged

Pages: [1] 2   Go Up
Jump to: