Need help with LED matrix

Hi! I’m sort of a noob when it comes to Arduino so I thought it would be best to ask for some help so I don’t damage something. I’m planning on making an LED matrix with the scheme I’ve drawn here: Imgur: The magic of the Internet . As you can see I’ve marked the rows and columns as well as the pins I plan to wire this thing to. I’m using an Arduino Mega 2560 rev3 btw. So my questions are: should I add resistors just between the matrix outputs and pins or should I have one connected to every LED (and what value should they be either way)? Also, is it okay to just connect the outputs of the matrix to Arduino pins as marked in my drawing (I know there’s ways to make it easier but I can’t really make a lot of adjustements I just want to know if this is possible the way it is) and can the Arduino handle all these LEDs on its own current-wise?

18 by 5 with 12 positions vacant.

That is some seriously weird matrix!

To drive a matrix, you need drivers. Since you are only planning it, this is a good time to plan it properly. There are various ways you could drive it, but in general, a proper purpose-designed driver such as the MAX7219 would be the way to go and this means it performs all the multiplexing for you so you get a consistent display. You probably do not need a MEGA 2560 either; a Nano would be appropriate.

The MAX7219 drives 64 LEDs in a 8 by 8 grid. Two of them will therefore drive up to 128 LEDs. Precisely what do you want your LED matrix to do?

I'm making a really simple 6-digit clock and I'm using a mega because I already have one that I'm not using for anything else. I was hoping to do this without any additional components except resistors. I also already wrote up some functions for displaying the digits, this one's for digit 5:

void z5()
{
  digitalWrite(c1, HIGH);
  digitalWrite(c2, HIGH);
  digitalWrite(c3, HIGH);
  digitalWrite(r1, LOW);
  digitalWrite(r1, HIGH);
  digitalWrite(c3, LOW);
  digitalWrite(r2, LOW);
  digitalWrite(r2, HIGH);
  digitalWrite(c3, HIGH);
  digitalWrite(r3, LOW);
  digitalWrite(r3, HIGH);
  digitalWrite(c1, LOW);
  digitalWrite(r4, LOW);
  digitalWrite(r4, HIGH);
  digitalWrite(c1, HIGH);
  digitalWrite(r5, LOW);
  digitalWrite(r5, HIGH);

}

I tried these functions out on a single digit that i put together with 13 LEDs in a matrix and they work. I'm just not sure if it's better to put the resistors for the LEDs just between the matrix outputs and the Arduino pins or to put one on every single diode. With the test digit I just put 220ohm resistors on the column pins and it seemed fine. I'm also not sure the Arduino can handle that many LEDs?

To keep the current on the common pins within the limits of the Arduino, you need to use 2k2 resistors, not 220 as long as no more than ten are lit at any one moment in the multiplexing. If that is adequate brightness for your purpose, go ahead.

Otherwise you need a driver and the cheap MAX7219 modules would be the best approach.

You can ignore the matrix provided and wire it to your own.

Or just get one of these:

I just tried it out with the 2k2ohm and it's bright enough for me. And just to make sure I understood, I should put the 2k2 resistors like this: Imgur: The magic of the Internet and it should be fine? (Also sorry for making you click links, I'm trying to insert the picture in the post but it's not working)

Yes, that would be the way to do it, given that you are driving the cathode commons LOW, one at a time and driving multiple anodes to light LEDs.

The thing is that while the resistors limit the current the anode driving pins have to supply, the cathode driver has to sink the current of all at once. If you had eighteen anodes lit with the 2k2 resistors, the LEDs would drop say, 1.5 V and if the drivers dropped another 0.6 V, there would be 3 V across the resistors, so each would pass 1.3 mA. If all eighteen in a row were simultaneously lit (06:06:06 - the bottom row) then the cathode driver would be sinking about 25 mA which is now acceptable.

To put an image in the post, you have to use the URL of that image. You gave a link to a Web page containing the image; I found ("Copy Image Location") the actual image URL.

(Some people on the forums will suggest you should upload the image to the forum itself and cite the resulting image link - it the forum software behaved itself and did not limit the size of uploads that might be a good idea but as long as the image hosting site permits them to be linked as imgur does, that is fine. :grinning: )

Okay, I get it now. Thank you so much for all of your help! :smiley:
Also, I tried using the Insert an image option with an Imgur link but it wouldn’t work ¯_(ツ)_/¯

bttshrbs:
I just tried it out with the 2k2ohm and it's bright enough for me.

But you are not yet multiplexing the display. This will make it much dimmer. If you scan one row at a time, it will be 5 times dimmer. If you scan one column at a time, you can use much lower value resistors, but the scanning of 18 columns will make it just as dim as when you scan by rows.

You should see how bright it looks with multiplexing, and then decide if it is bright enough.