Wiring multiple LED - best way

I'm trying to wire up a matrix [5x5] of LEDs in the best possbile way. I've got my Arduino Mega hooked up to a breadboard. This one: http://www.coolcomponents.co.uk/catalog/product_info.php?products_id=417

I'm just trying to find out how best to wire up the 25 leds and control them individually [via Flash]. At the moment i'm connecting each individual LED to the breadboard and in turn to the Arduino. I'm just wondering if there's a less wire heavy way of doing it.

I'm a total novice when it comes to electronics so any help is greatly appreciated.

Have a look at this tutorial.

http://arduino.cc/en/Tutorial/RowColumnScanning

Same method shown for that 8x8 can be used for a 5x5. Same with the code. A few tweaks and your good to go.

Thanks digimike, I'm a total noob when it comes to electronics and wiring. It looks idea. The matrix of LEDs is self made - unlike the fancy pre-made on in the tutorial - that shouldn't effect the principles of it right?

nope

digimike, that's a nice tutorial. I found this one as well which deals with the Mega [which i have]. http://www.tigoe.net/pcomp/code/category/arduinowiring/424

I'm a bit lost though. How does the Arduino command the LEDs in the center of the matrix. Since their not directly connected to an output. It's more the electronics of it, i understand the sketch code. That might sound like a duff question, but i am a noob to this after all.

Actually they are tied to an output pin. Look at the schematic diagram. The anodes are in line with one of the row pin. While the cathodes are in line with one of the column pins. So its just a matter of controlling the row and column to select the LED you want to light.

Lets say you want to light the LED that is 5 rows in and 5 columns down. You will set row 5 to HIGH and column 5 to LOW. So any single LED in the matrix can be light as needed. Now there are some limitations here as you can imagine. Lets refer to the LEDs like this: LED(row,column). So if we have LED(5,5) lit and we want LED(5,6,) to light then we ground column 6. Now if we want to add just LED(4,5) to this we run into a problem. If we send +5 to row 4 we will get both LED(4,5) and LED(4,6) lit. So there are limits in the patterns and things you can do with this.

its like a multiplication table ;)

Ah! I see, it makes sense now. Thanks!!

Am i right in saying that i need a 1k resistor before the transistors in order for them to switch?

yes you need one, but not to switch

the base and the emitter of most transistors might as well be connected, when you switch a digital output to toggle the transistor your connecting 5v tru the transistor direct to ground

after that its a dice roll to see which one will smoke first, the arduino or the transistor

the resistor tween the arduino and the base of the transistor limits current to safe levels

So the resistor on the transistor is just to protect the arduino / transistor? I'm still unsure on how to wire the transistor. Any guides on it - the three pins are foxing me!

http://www.kpsec.freeuk.com/images/tranload.gif

the load is your led, the box on the left would be the 1k resistor going out of the arduino to the base

(this is a npn transistor btw)

the load is your led

The load is your LED plus the LED's current limiting resistor. This is another resistor not to be confused with the one in the base.

good catch

ok, so the LED connects directly to the transistor [via the LEDs cathode] the 1k resistor connects to the middle pin of the transistor and the final pin of the transistor goes to the ground??

yes, and as mike pointed out dont forget your led resistor too

so

V+ to led resistor to led to collector

arduino to 1k resistor to base

emitter to ground

1 led, 1 transistor 2 resistors

here is an example

go here http://www.falstad.com/circuit/

and import (copy n paste) the following into the applet (its in the file menu)

$ 1 5.0E-6 10.20027730826997 50 5.0 43
t 448 224 512 224 0 1 -4.4947280294839125 0.0985395451917421 100.0
g 512 240 512 272 0
r 448 224 384 224 0 10000.0
162 512 160 512 208 1 2.1024259 1.0 0.0 0.0
r 512 160 384 160 0 220.0
R 384 160 336 160 0 0 40.0 5.0 0.0 0.0 0.5
s 384 224 320 224 0 1 false
R 320 224 288 224 0 0 40.0 5.0 0.0 0.0 0.5

and pretend the switch action is being done via the arduino

Yeah, so there's also another resistor that the LED conntects to - which in turn in connected to the arduino.

Here's a front shot of the matrix. It's 8x8 on a thin(ish) piece of mdf.

and the resistors attached to the front of the board - connected on the other side.

Here's a shot of the back. I've readied the pins of the LEDs to be soldered into columns and rows.

thats a heck of a perfboard!

so what transistors are you going to use

I'm guilty of not starting out small. ;D Looking to get this initial matrix working then try make a bunch more to make some sort of wall. But that's way off.

The transistors [npn type] i'm using have the following on them: 2n3904 f9 c Does that sound right?

What does 'prefboard' mean?

Also thanks for all your help Osgeld/Grumpy_Mike - really appreciate it!!

yea a 3904 can handle ~200ma (give or take depending on who made it)

and here is a datasheet with pinouts if your still mixed up with that http://www.fairchildsemi.com/ds/2N/2N3904.pdf

and perfboard is just a name for a electronics board perforated with holes, sometimes they have no copper pads, sometimes they do, sometimes they have all the holes connected and you cut away the copper

protoboard, perfbord, veroboard, stripboard are common names to different kinds depending on region and whatnot

http://www.instructables.com/files/deriv/FZV/O1O1/G1XC0IHH/FZVO1O1G1XC0IHH.MEDIUM.jpg