Can anyone please help me fix this LED flickering? LEDs connected in parallel

The circuit function like this

Right transistor is used as a variable resistor. right transistor starts out turned on by 3.3k.

left transistor is used as an over-current sensing switch, and R is the "sense resistor" or "set resistor" that triggers left transistor when too much current is flowing.

The main current flow is through the LED's, through right transistor, and through R. When too much current flows through R, left transistor will start to turn on, which starts turning off right transistor. Turning off right transistor reduces the current through the LED's and R. So we've created a "feedback loop", which continuously tracks the current and keeps it exactly at the set point at all times.

Resistor 3.3k can change to any value base on the gain of the transistor.
you can keep it 330 ohms.

The transistor can be the one you used now, or you can try 2N2222 or BD139

wvmarle:
Yes, that was a typo.
Corrected it when I saw your message.

That power is because there will be 400 mW for the transistor to dissipate.
Power supply 5V - 3.2V to the LED, 0.7V to the bottom transistor (if I understand the circuit correctly that one doesn't carry any current - still hoping for a more detailed explanation by @billhowl), 1.1V left for the top transistor to drop. 350 mA x 1.1V = 385 mW.

To select a suitable transistor: open up digikey.com or mouser.com web site, set all your requirements (at least you'll want to know the minimum voltage, power rating, CE current, package type), then get the cheapest available that does what you need it to do.

Thanks. Sorry, but I still don't understand some of the things you are saying. Ok, I will be using a 5V DC power supply to individually control 13 LEDs. How exactly is the 400mW thing related? I still don't get it. Can you please explain? Let's say the resistor I will be using is 2 Ohm. So, what is 400mW? is that some kind of rating of the transistors? Because I'm confused. You are saying Power supply but it is too little to be the rating of the power supply for 13 LEDs.

Your power supply is rated by current (350 mA per LED x 13 = 4550 mA so you need at least a 5A supply for all those LEDs).

That 400 mW is the amount of power the transistor has to deal with, that's coming out in the form of heat.

Make sure you understand the difference (and relationship) between power, current, voltage and resistance. Start with Ohm's Law.

billhowl:
The circuit function like this

Right transistor is used as a variable resistor. right transistor starts out turned on by 3.3k.

left transistor is used as an over-current sensing switch, and R is the "sense resistor" or "set resistor" that triggers left transistor when too much current is flowing.

The main current flow is through the LED's, through right transistor, and through R. When too much current flows through R, left transistor will start to turn on, which starts turning off right transistor. Turning off right transistor reduces the current through the LED's and R. So we've created a "feedback loop", which continuously tracks the current and keeps it exactly at the set point at all times.

Resistor 3.3k can change to any value base on the gain of the transistor.
you can keep it 330 ohms.

The transistor can be the one you used now, or you can try 2N2222 or BD139

Thanks for explaining. How do you determine the gain of the transistor?

I mean, I know you are saying the resistor rating depends on the gain of the transistor. But on the other hand, it seems quite important because the current in the above diagram seems to be limited by exactly the openning and closing of the two transistors. So, the gain must be important. How exactly, do you choose the right transistor? I'm talking about the left transistor.

Additionally, I was told that transistors don't open gradually. The guy at electronics shop said, at any given time they are either open or closed? Obviously, that can't be true because otherwise, the circuit which is shown above could not monitor and limit led current. is that right?

Anyway, how do you choose the right resistor for the base of the transistor? What is the purpose of selecting a resistor value for the transistor base? to keep the transistor base from failing or to get it to open fully or what? can anybody please explain how to pick the right resistor?

Cheers.

arduinoware:
Thanks for explaining. How do you determine the gain of the transistor?

By reading its data sheet.
The actual gain doesn't matter much anyway as it's self-regulating. Just think of what happens if the current increases (and the voltage over the small resistor increases) or decreases.

Additionally, I was told that transistors don't open gradually.

BJT transistors (commonly called "transistor") open quite gradually and linearly with the base current. That's why they're so useful as amplifiers in audio circuits and the like. MOSFET transistors (commonly called "MOSFET") indeed act much more as switches, and are primarily used as such.

Anyway, how do you choose the right resistor for the base of the transistor? What is the purpose of selecting a resistor value for the transistor base? to keep the transistor base from failing or to get it to open fully or what? can anybody please explain

Not too small: it protects the Arduino's port, so at 5V and 20 mA max. pin current at least 250 Ohm.

Not too big: it has to be able to open the right transistor more than enough to switch on the LEDs. So if you have a look at the datasheet of the 2N2222 you see the gain to be around 50. You want 350 mA for your LEDs so you need to be able to supply 350/50 = 7 mA base current. The collector is at +0.7V (due to the resistor) so the maximum resistor value would be (5-0.7)/0.007 = 614 Ohm.

Your resistor value of 330 Ohm is good. The 3.3k as suggested is too high for this total current and transistor gain. In the end you have to supply a bit too much current, and the surplus is siphoned off by the left transistor as needed.

billhowl:
The circuit function like this

Right transistor is used as a variable resistor. right transistor starts out turned on by 3.3k.

left transistor is used as an over-current sensing switch, and R is the "sense resistor" or "set resistor" that triggers left transistor when too much current is flowing.

The main current flow is through the LED's, through right transistor, and through R. When too much current flows through R, left transistor will start to turn on, which starts turning off right transistor. Turning off right transistor reduces the current through the LED's and R. So we've created a "feedback loop", which continuously tracks the current and keeps it exactly at the set point at all times.

Resistor 3.3k can change to any value base on the gain of the transistor.
you can keep it 330 ohms.

The transistor can be the one you used now, or you can try 2N2222 or BD139

Thanks. But I drew this circuit in a circuit simulator (Every Circuit) and it did not work. The right transistor did divert the current, but upstream of the right transistor the total current was the same. Any idea why it does not work in the simulator? Is this circuit definitely going to work in real life with a 2N2222 transistor and the variables that you are stating?

Then I drew a slightly different circuit and it worked:

Try it yourself, it been used for many place, it work.

It looks like the circuit you try to simulate is different from the schematic posted before. The collector of the left transistor should connect to the 330R resistor and the base of the right transistor.

wvmarle:
It looks like the circuit you try to simulate is different from the schematic posted before. The collector of the left transistor should connect to the 330R resistor and the base of the right transistor.

Yes. I know. The original schematic that was posted before did not work in simulator. so I posted this one.

What do you think of the one I posted.? The one in black background? Can it work?

Cheers

arduinoware:
Yes. I know. The original schematic that was posted before did not work in simulator. so I posted this one.

Simulator fail.

What do you think of the one I posted.? The one in black background? Can it work?

No.

Simulator fail.

Or more likely you did not put it into the simulator correctly. Given your effort that you think works shows you do not have much experience of using and more importantly interpreting simulators.

Grumpy_Mike:
Or more likely you did not put it into the simulator correctly. Given your effort that you think works shows you do not have much experience of using and more importantly interpreting simulators.

Thanks Mike. I did manage to get it to work on the simulator. Your grumpy username suits your grumpy posts, by the way.

Please send my regards to moaning "Coding Badly".

Grumpiness and moanership must be a qualification needed to post on this forum.

Cheers.

arduinoware:
Grumpiness and moanership must be a qualification needed to post on this forum.

Hey, that's exactly how the BOFH manages to continue to deal with users :slight_smile: