1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

How to Wire an LED

Discussion in 'Electronics Videos' started by unix60959, Jan 23, 2012.

  1. konradIC13

    konradIC13 Member

    Joined:
    Jun 15, 2012
    Messages:
    90
    Likes:
    0
    Location:
    Poland
    Yeah, i took those forward voltages from the RGB LED description in shop i buy it from, and yeah ill want to light up multiple leds (R,G,B,RG,RB,GB or RGB) at same time thats why i use transistors.

    Ill try out 2N4401 transistor (it will be BC337 since i read it can be used as replacement) with 1k base resistor
     
    Last edited: Jun 22, 2012
  2. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    How many LED's do you need to light up? The transistors reduce the amount of current required from the MCU but 1k resistors fed from 5 volts will still draw a pinch more than 4ma of current per I/O line.

    There are three qualifications for the power supplied by an MCU I/O line. Per pin limit (generally 20ma or so) Per Port limit (generally 100ma or so) and the whole chip limit, which isn't generally much higher than a whole port can handle. You can get the exact numbers from the PDF for your chip and you'll need to worry about them to make this work. If you can't drive all the I/O lines at the same time you'll have to interleave them or use a separate external driver.

    Many users have suggested using shift registers as simple LED drivers, they can be multiplexed easily and virtually eliminate current draw from the MCU completely.
     
  3. konradIC13

    konradIC13 Member

    Joined:
    Jun 15, 2012
    Messages:
    90
    Likes:
    0
    Location:
    Poland
    Hello,

    Using multiplexer seems indeed like good idea, ill consider it.
    I also found another (possible?) way to solve my problem. I have read that you can use an IC output to 'sink' the current instead of 'delivering current'. In that case when the output of IC would be low (low voltage is max 0.9v) it would sink current and the led will light up, schematic:
    View attachment 65098
    I think in that case i wont have to worry about maximum output currents of ports? But also i would have to change diode to 'shared cathode'?
     
    Last edited: Jun 23, 2012
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. audioguru

    audioguru Well-Known Member Most Helpful Member

    Joined:
    Mar 16, 2004
    Messages:
    32,575
    Likes:
    950
    Location:
    Canada, of course!

    Your last schematic shows PNP transistors instead of NPN transistors so it WILL NOT WORK!
    The transistor LED driver still has base current (even when it is an emitter-follower) so of course you must worry about the maximum current of ports.
     
  6. konradIC13

    konradIC13 Member

    Joined:
    Jun 15, 2012
    Messages:
    90
    Likes:
    0
    Location:
    Poland
    OMG silly me, i forgot to rotate those transistors (i have no idea why they got placed like this) here is fixed schematic. I checked again the electrical datasheet of ATmega8 and it has 100mA curret limit per port.

    As i said i fixed circuit, with 2k resistors at base the base current draw should be around ~1.8mA and then 2N4403 transistor will supply around 28mA (so its plenty to supply 1 20mA LED since one transistor will supply only 1 led)

    Here are fixed schematics for NPN and PNP switches.
    View attachment 65121 View attachment 65122

    These are 'complete' schematics so there will be no more leds, only 3 outputs, 3 transistors and RGB (3 leds in one) to drive. I think ill move the conversation to the microcontrollers forum since its slowly becoming something more than just 'wiring leds' :p
     
    Last edited: Jun 24, 2012
  7. audioguru

    audioguru Well-Known Member Most Helpful Member

    Joined:
    Mar 16, 2004
    Messages:
    32,575
    Likes:
    950
    Location:
    Canada, of course!
    Since the ATmega8 has outputs of up to 100mA and you have only one RGB LED then why are you using the transistors?
     
  8. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    100ma's per entire port (and a pinch more for the chip I think) at 20ma the bulk resistance of the driver will kick in and you'll lose voltage, this is also perilously close to the maximum allowed current on the I/O line, not something you want to continue drawing for extended periods of time, the bypass transistors shows a practical design process, but it also depends on the duty cycle expected, granted erring on the side of caution is a good idea considering a fault condition could fry the chip.
     
    Last edited: Jun 25, 2012

Share This Page