Continue to Site

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.

  • 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.

How to Wire an LED

Status
Not open for further replies.
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:
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.
 
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:
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.
 
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:
Since the ATmega8 has outputs of up to 100mA and you have only one RGB LED then why are you using the transistors?
 
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:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top