This is similar to How to drive a 20mA LED From a 4mA max GPIO Pin except that I need a little more hand-holding in order to understand what is happening.
For background, I'm a software engineer and currently only know enough about electronics to successfully test a 9V battery will my tongue.
I have an Arduino Uno board which I have rigged to separately control 3 LEDs blinking in a "chase lights" type of configuration. I have connected each GPIO pin directly to an LED, a resistor, and back to the board's +3V ground pin. The software strobes the GPIO pins at intervals to achieve the desired effect.
With one LED wired, everything looks great. When adding a second LED to each of the 3 small circuits (to "extend" my string of chasing-lights), the LEDs dim considerably. My plan was to eventually wire a string of 10 LEDs for each circuit for a total of 30 LEDs. Obviously, if I can't light 2 LEDs, 10 is out of the question.
So I thought of using a transistor for each circuit with the GPIO merely providing the "trigger" for lighting the strand of 10 LEDs. I have wired-up a few LEDs, a resistor, and the transistor, and connected it all to a 9V battery. It's dark, as expected. There is only one base pin on the transistor, so obviously the GPIO pin should be connected to that, but how should I correctly complete the circuit back to the Arduino board?
I experimented by taking a 3V battery and connecting the negative terminal to the transistor's emitter pin and then touching the base pin as a trigger and it seemed to work, thought the LEDs flickered a little. That might just be because my hands weren't super-steady. Is this the right approach for working with the Arduino's GPIO pins?
Here are all the electrical specs for the components I have in front of me, because the math matters, of course.
Arduino GPIO: 5V LEDs: NTE30143 5V 25mA (continuous forward current) Transistor: 2N4401 600mA
What's the "proper" way to use the Arduino's GPIO pins to light a string of 10 LEDs? Can it be done with the components above, or should it really be done with a more complex circuit?
I'm building this as a prototype for some elementary school students to build themselves, and I'd rather make the circuit as simple as possible.
(Bonus points for explaining where the resistors need to go, what their values need to be, and why they need to be there in the first place :)
I forgot to mention that
I want to wire each string of 10 LEDs in series, not in parallel I want to minimize the amount of wire required. These LEDs will end up being maybe 4-5 inches apart and the entire string of 30 LEDs will make a big loop, so I don't want to string each LED individually. I'd like to have 3 large loops of 10 LEDs each with all of the controls in a single place.
One last requirement (I think): this has to run off of batteries. No mains power. :)