Did I forget anything?- 72 LED Array loop cycle for 6 months.

Hi all, I just got my Arduino a week ago... so much fun! I've been reading the forums and feel like after all of my research on here it's time to check my ideas!

The Concept: I'm working up to make a 72 led array in 6 sets of 12 yellow LEDs They are programmed to turn on and off the 6 sets throughout a 6 month period.

My Plan:

Program: Adjust http://arduinoarts.com/2011/08/arduino-tutorial-the-knight-rider program to have longer delays and use only 4 pins. ie. adjust "int timer = (*) ;" * to the equivalent of a full day Then add another "blink" code with a long delay on the 2 remaining sets of 12 LEDs for 2 more pins for a faster sequence running at the same time.

Hardware: Arduino LEDs Wires Resistors Transistors Breadbord

Hardware Layout: Pins 3-8 each run through->appropriate resistor-> base pin of appropriate transistor then run 12v external power->appropriate resistor->12 LED array-> current pin on transistor-> exit pin on transistor to ground.

Questions: Can I run the whole lineup through a single transistor or do I need one for each output pin? What would said transistor(s) appropriate value be? How do I figure out the appropriate resistance values for the pin-> Transistor resistor values? and the Power-> LED resistor values If some of my LEDs are mismatched do I run them in series or parallel? (some dimming is not a big deal, they are mostly hidden/subtle lights anyway)

Thank you everyone who replys on these boards! I have already learned so much! and am excited to learn even more! -Andrew

One thing to watch out for is that the Arduino clock isn't very precise so it will gain or lose time over long intervals (minutes per day, possibly a day or two over six months).

You need one current limiting resistor for each set of LED's in series. You can put as many LED's in series as you want as long as the supply voltage is higher then the combined forward voltage drop. Say you had LED's with a 2V drop you could string about 5 of them together before you need more than 12V. If you set them up as three strings of 4 LED's (8V drop) you could use the 12V supply. The remaining voltage (12-8=4) drops across the resistor. To get the typical 20mA through the LED's you would need a resistor of (4V / 0.020A =) 200 ohms. Each set of 12 lights (three strings of four) will take 60 mA. All six strings together will need 360 mA.

Can I run the whole lineup through a single transistor or do I need one for each output pin

You need a transistor for each output pin.

Any output that's got more than 40mA in-or-out of it needs a transistor. If you need the outputs to switch independently, they all need their own transistor.

What would said transistor(s) appropriate value be?

Look at the power & current ratings, and choose an NPN or PNP transistor depending on how it's connected.

For switching applications, the power/wattage rating of the transistor is not as important. i.e. a light switch does not consume power and it does not get hot (when working properly). But, be aware that transistors (and MOSFETS, etc.) are not perfect switches. They do consume some power, and in high-current applications they can get hot (or burn-up).

How do I figure out the appropriate resistance values for the pin->

After knowing the voltage & current, you calculate the resistance needed to obtain that current with [u]Ohm's Law[/u], which defines the relationship between Voltage, Resistance, and Current. Look at the voltage & current ratings for the LED. The voltage gets divided among the LED, resistor, and transistor. The voltage across the transistor (when on) is less than 1 volt, and you can ignore it. The voltage across the LED is fairly constant (when on), and the brightness is determined by the current through it. The same current flows through all three.

So, lets say you've got 12V with 2V dropped across the LED. That leaves 10V across the resistor. If we want 20mA, we calculate 10V/.020A = 500 Ohms.

If some of my LEDs are mismatched do I run them in series or parallel?

Until you fully understand Ohm's law and series/parallel circuits, I'd recommed a separate resistor for each LED, and wiring the LED-resistor combinations in parallel.

Use a transistor on the output pin if: A) The current being switched is more then about 20mA (40mA absolute max) B) The voltage being switched is any more than the Arduino supply voltage (5V)

If some of my LEDs are mismatched do I run them in series or parallel?

If they are mis-matched in current draw you need to run them in parallel because every point in a circuit gets the same current. It doesn't matter if they are mis-matched in forward voltage drop but that will change the current limiting resistor needed.

John and Doug, thanks for the replies!
I just got three types of NPN transistors a 2n2222, 2n3904, 2n4401

in the 2n2222 Data sheet:
"
SYMBOL PARAMETER CONDITIONS MIN. MAX. UNIT
VCBO collector-base voltage open emitter
2N2222 − 60 V
VCEO collector-emitter voltage open base
2N2222 − 30 V
VEBO emitter-base voltage open collector
2N2222 − 5 V
"

-That means that from Arduino output pin → base pin, i’m not supposed to apply more than 6v, but the power supply going into the collector at 12v is ok still, correct?

-Also do I not need a resistor from Arduino to Trans. base? I thought I herd somewhere that it was safer? true?

-I’m understanding Ohms law better now, refresher from grade school physics :slight_smile: I’m also using this array wizard to check my designs: http://led.linear1.org/led.wiz

Just making sure I don’t blow anything, still learning. Thanks!!!

It works!

the “test circuit”:
-5 (2n2222) transistors, “emitter” terminals connected to Arduino ground and negative of power supply
-5 900ohm resistors, connected to each “collector” terminal of transistors
-5 2.1v 20mA LEDs connected to the other end of the resistors
-LEDs, all connected to positive terminal of 12v dc power supply
-Each Base terminal of transistors connected to pins 3-7 on Arduino

Next it to write a stable code that will get me a relatively predictable sequence for each day of the 6 month period.
John,

One thing to watch out for is that the Arduino clock isn’t very precise so it will gain or lose time over long intervals (minutes per day, possibly a day or two over six months).

I’ve read on the forums somewhere that there is a way to work with the counter’s quirks to make it more reliable. I’m going to poke around and try to find that again.
-or-
This solution may be a bit archaic, but if I simply put the power supply to the Arduino on a hardware store timer to flip off for a bit at like 4 in the morning the Arduino can restart it’s sequence each day and hopefully will have close to the same events each day at a predictable time…

Does my schematic for the test circuit seem ok?
I attached some pictures too, (I know all of those exposed wires are silly, but it’s a test :stuck_out_tongue: )

Code: (slightly altered Knight rider circuit, going for a sort-of randomish sweep type array)

int pinArray = { 3, 4, 5, 6, 7};
int count = 0;
int timer = 100;

void setup(){
for (count=0;count<8;count++) {
pinMode(pinArray[count], OUTPUT);
}
}

void loop() {
for (count=0;count<6;count++) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count + 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer2);
}
for (count=6;count>0;count–) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count - 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer
2);
}
}

test1.jpg

test2.jpg

Any output that's got more than 40mA in-or-out of it needs a transistor.

sp. "Any output that's even close to 40mA in-or-out of it needs a transistor. "

I think that because the Base/Emitter junction acts a a diode straight to Ground you are supposed to have a resistor between the Arduino pin and Base to limit the current draw. You don't need much current because the transistor has 'gain' (switches more current than comes in the Base). A 1K resistor (5 mA current) sounds about right.