2

enter image description here (the schematics is just an example, I will choose different resistors and transistors) I started to design my own Xmas PCB tree. I want to control 10 LEDs (2.1[V] drop, and 20 mA IF ) with an ATtiny5 microcontroller PWM pin.

Doing my research, I found that I can't put more than 2 LEDs in parallel on one pin of the microcontroller because there is a limit of sink of 40 mA and is possible if I go over this value to break the microcontroller.

The only solution that I found is to control the LEDs through a transistor that the source is connected to the VCC of microcontroller that can sink upto 200mA. Is there something that I am missing?

  • A very warm welcome to the site. Not only is there a source/sink limit per pin but there's usually a source limit across sets or banks of pins and sometimes a sink. You may have already seen that. It's another reason to use external drivers. (Don't use a ULN2003 if it's suggested, much too inefficient and wasteful compared to modern components.) – TonyM Oct 27 '22 at 12:50
  • 2
    Are you sure you really want 20mA per LED (ie. have you tested it)? Often modern LEDs are quite bright at a few mA. That would mean you could use a direct drive or use an inexpensive and efficient solution such as a ULN2003A, assuming you need a few drivers, or just a single MOSFET or BJT and a resistor otherwise. – Spehro Pefhany Oct 27 '22 at 13:25
  • 1
    Most modern LEDs do not need 20mA. That will usually be super bright. Depending on how blindingly bright you want it. You can most likely use 5mA per LED. Check the datasheet for the LED. – Aaron Oct 27 '22 at 15:44
  • @Aaron, On *"Most modern LEDs do not need 20mA"* I think you meant indicator LEDs don't. Illumination LEDs sure do and much more. On the OP's question, they're trying to illuminate and 20 mA is reasonable, though they may be able to use more efficient LEDs. – TonyM Oct 27 '22 at 15:56
  • Perhaps helpful/related: https://electronics.stackexchange.com/q/11046/2028 – JYelton Oct 27 '22 at 16:50
  • Thank you! I will look over and see, honestly, I am not sure even know how to do it, but Aaron is right to use only 5mA pe Led, I just tested this today, and the luminosity is very good. I think I will do it with a single MOSFET. Also, I ll need to see what battery to choose because I want it to be like a keychain so the battery should be very small, maybe 2 LR44 should do the job. – Stefan Mihai Lorincz Oct 27 '22 at 17:55
  • An LR44 is a 1.5 V cell with 150 mAh capacity. Your 3x 5 mA LEDs would last 10 hours and you're wasting a lot of power in the series resistors. If you're looking for a low power design for batteries, you'd need to rethink it a lot. – TonyM Oct 27 '22 at 19:32
  • I will put them in parallel for safety reason. What do you mean by series resistor? I dont use resistors in series. I will use 2 x LR44 and it will not be on all the time, i will also add a slide button to turn on/off. – Stefan Mihai Lorincz Oct 27 '22 at 20:08
  • (a) I think it's unsafe to put coin cells in parallel. (b) Your schematic shows a resistor in series with each LED. – TonyM Oct 27 '22 at 20:44
  • All right, so, that was a misunderstood, (a) I ll put the coin cells in series, not in parallel, so I can supply enough voltage for uC also. (b) why I am wasting a lot of power with the resistors? If I put only one resistor for all of them, if one LED will break, all the current will change over the LEDs so that's why I want to put them in parallel and each of LED to have its own resistor. – Stefan Mihai Lorincz Oct 28 '22 at 04:59

1 Answers1

0

Here is what the datasheet specifies:

enter image description here

control the LEDs through a transistor that the source is connected to the VCC of microcontroller that can sink upto 200mA.

If using PMOS transistors is the selected solution, you should do this connection for each one, connect each gate to an IO pin, and connect the drain to each LED (with its other terminal to the GND).

If you prefer NMOS transistors, they should be connected do GND, not Vcc.

enter image description here

devnull
  • 8,447
  • 2
  • 15
  • 38