Hello, I'm fairly new to this and I have what I think is a rather basic question.
I have about 20 LED strings and I want to control each string separately. Only 4 strings will be on at the same time. Is this possible with Arduino? Is there maybe something else that might be more suitable for this?
Thanks.
Sure, is possible.
Supply power to each string from 12V or whatever source they need.
Use an NPN transistor, such as 2N2222, to control the ground of each strip.
The arduino then controls the transistor.
You need a 150 ohm resistor between arduino and transistor base.
Transistor emitter goes to ground.
Transistor collector goes to the "negative" of the LED string.
"Positive" of the string goes to +12V or whatever power source it needs.
May need a current limit resistor in series with the LED String, or it may be built in.
So, if I understand you correctly, I need an NPN transistor for each LED string. That's 20 transistors. How would the arduino control that many transistors? (Or did I get you wrong and I only need 1 for all?)
I need an NPN transistor for each LED string.
Yes.
How would the arduino control that many transistors?
If there are not enough outputs then use a mega or some form of port expander. Shift registers are a beginners favorite.
Thank you for your answers.
I looked into shift registers and it seems that's what I need. They also seem pretty simple to use.
I couldn't find any 2N2222 transistors, only 2N2222A ones. Would these work as well?
So, if I got it all right, it's going to look like this:
Arduino connected to 4 shift registers that are connected to 20+ transistors (base). Between the registers and the transistors are resistors.
Transistors are connected to LED strings (collector to negative).
12V power source goes to LED string (positive), shift registers and arduino.
Ground goes to transistors (emitter), shift registers and arduino.
Few more newbie questions (sorry I'm a software engineer with a limited knowledge in electronics and electricity)
Why do I need transistors?
Does it matter how many LEDs I have in each string?
What are my 12V power source options?
the 2N2222A transistors should work fine. You need them to supply enough current to drive all them lights! If you tried to drive them just with the pin outs of the Arduino, then you wouldn't have enough current.
Why do I need transistors?
Because the shift registers can't delver the current you need at the voltage you need.
I couldn't find any 2N2222 transistors, only 2N2222A ones. Would these work as well
Yes.
Between the registers and the transistors are resistors.
Yes the wiring sounds right.
Does it matter how many LEDs I have in each string?
The more LEDs the more current you need. Make sure this is less than 80% of the current rating of your transistor.
the 2n2222 transistors are really hard to get the a version is easy to come by the metal can 2n2222 are a collectors piece now, i have alll of them as i collect
You could multiplex the 20 strings through a (4x5) grid of 20 transistors.
Then you only need 9 pins, but you can only cycle one string at a time, so they would be slightly dimmer if more than one string was 'on'.
But, I would get a second opinion because I'm new here!