3x3 LED matrix wiring [now with picture]

hello, complete noob here.
say if i would want to make a 3x3 matrix, the correct way to do it is to connect all the cathodes of the LEDs to ONE wire together and connect that wire to the GND of the arduino board.
right?
thanks!

a) Make sure you know about The Resistor.

b) Be sure you know about the power limits of your Arduino. There's a "per pin" limit, and an "sum of all pins" limit... and you can exceed the latter without exceeding the former on any single pin. (You just switch the LEDs on and off with a transistor if power is a problem, and power the LEDs from something outside the Arduino.)

c) 1) If you want to turn all 9 on together or not at all, yes, what you said... BUT: that might exceed the power limits.

c) 2) Assuming you want to turn any combination of LEDs on or off....

Do wire from all of the cathodes or anodes to ground. (I always confuse anode/cathode... but it's ok. If the circuit doesn't work, just turn the LED around. It will act like an open circuit if backwards)

From 9 data pins of the Arduino, connect 9 resistors, and from the other end of each, go to the unused-so-far pin of the LED. (No, you can't "get away" with one resistor "downstream" on the common path to ground.)

That should work!

===
There's an alternative that's a little harder to explain: The wired-together pins of the LEDs can be "fed" from a high voltage, and then the "bottom" of each of the 9 paths go to bround through the Arduino. If some expert knows this would REALLY be better... (some pins are better at "sinking current" than at "sourcing" it), he should step in and "complain" about my suggestion.

But with my suggestion, it is harder to go wrong. If you use the alternative just proposed, and you are not feeding the "top" of the LED set from the same voltage feeding your Arduino... and I mean the voltage AFTER the on-board voltage regulator, then you MUST use transistors to switch the current through the LED paths.

thank you for your detailed answer!
yes, in the end i want to go with option 2, that means controlling each led individually!
i thought i could do this with multiplexing by using just 6 pins (3 rows + 3 columns).

ok here is my first attempt and guess what, it doesnt work :frowning:

the only thing i can get to light is the lowest row, but if i want to light the middle row for example with this:

digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);

digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);

nothing happens.

is my wiring setup wrong maybe?

pins 0 and 1 are normaly used for serial connection. try another one i think

that did the trick! thanks!

is my wiring setup wrong maybe?

Yes, the lack of series current limiting resistors will destroy the output pins and/or leds if you ever do get them to turn on.

Nothing lighting presently? Perhaps you forgot the command that tells the pins to become an output pins, pinMode(PINx, OUTPUT);, one command for each pin you will be using as an output.

Only if you post your complete sketch can we tell.

Lefty

Ah! Sorry! You DID include the word "matrix" in your subject line.

When you spoke of connecting all the cathodes and taking them to ground, I thought you were thinking of using 9 i/o lines to turn LEDs on and off. I did see the "matrix", but thought you were merely describing their physical arrangement.

I hope you got the resistors in place in time? You need 9, by the way.

But with them, and POV (persistance of vision) you can make the display look like any combination of LEDs is lit.

Remember to check the total power requiremed against the Arduino's ability to deliver, as mentioned in my first post.