16x8 led multiplexing without additional IC's

I ordered two 8x8 led matrixes and i already soldered them to the pcb for easier interface. But as i've done some research i realised that i could use many IC's to help me control it but as i dont have any of those i could just control it using arduino mega (by connecting all of the 8 the rows to 8 outputs and colums to other 16 output pins of the mega. So if i put 200ohm resistors infront of either all of the 16 colums or the 8 rows i would reduce the current to around 20mA. But how would i exactly control 1 single led in 1 fraction of the time and move to the next one? I watched a tutorial on youtube on how to multiplex and the guy had mosfets for controling each individual row because of the maximum 150mA (or somewhere around there) current output of the arduino. So my question is if i simply output 5V (HIGH) to one row and 0V (LOW) to the column of the led i want to control, would arduino draw just the 20mA of the led i am controlling or would it somehow draw from other leds too? I dont quite understand how this works :confused:
Thank you all for your future replies!

Hi mate 115

For that you can use 1 code like this example

int line1 = 3;
int line2 = 4;
int line8 = 10;

int Col1 = 11;
int Col2 = 12;
int Col8 = 18;

void setup()
pinMode(line1, OUTPUT);
pinMode(line8, OUTPUT);

pinMode(Col1, OUTPUT);
pinMode(Col8, OUTPUT);

digitalWrite(row1, LOW);
digitalWrite(row8, LOW);

digitalWrite(Col1, HIGH);
digitalWrite(Col8, HIGH);

void loop()
//Suppose you want to turn on the 3 led of the first row
//The Anode of the led must be on the row and the catode on the column
//I highly recommend adding transistors to protect the Arduino (NPN in the row and column PNP )
digitalWrite(row1, HIGH);
digitalWrite(Col3, LOW);
digitalWrite(Col3, HIGH);
digitalWrite(row1, LOW);

If you will put both 8x8 matrix with the columns in common, only add more row in the code but remmember in the void setup() start like outputs and add the first states of those

Hi, Roberto!
First of all, thanks for the reply.
But there is one thing left i want to ask. Could i just put PNP transistors infront of the rows and columns and connect everything to external power supply, and control the transistors with arduino? Or could i just connect it to arduino 5V (i could, but would it be safe?)

I can smell burning. Can anyone else smell it?

But seriously... you don't want to use ICs but you are ok about using transistors? What do you think ICs are constructed from?

Being less sarcastic (sorry) what you should be using is 2 max7219 chips. Easiest and best.

If you really want to explore the transistor-only route, yes, you can put pnp transistors on the common anodes and connect the cathodes to Arduino pins, or put npn transistors on the common-cathodes and connect the anodes to Arduino pins. Brightness will be limited either way but might still be good enough. For maximum brightness, put pnp on anodes and npn on cathodes!


totally agree with PaulRB, the best way is using another IC but if you dont want to do that and use transistor, I prefer using both transistor, because if you only used one type and using directly the arduino to give power to the led’s or to ground the leds (this more dangerous to arduino) you can damaged the arduino, always the best way is completely isolate the arduino from the power section.

if dont want to used IC or any transistor(BOTH) you can do it directly take the pin to the row and the pin to the column, but you will not have full brightness of the led, because change the state of the led in high speed is almost like have working the led with PWM.

If you choose the transistor way, use a source of 9V and calculate the resistor again because you have a voltaje drop by the transistors.

[V(source)-V(PNP)-V(NPN)-V(LED)]/I = R

Well, the burning smell is getting stronger, so i'll just remind the OP that Arduino pins can be damaged if subjected to more than 5V, or having to sink or source more than 40mA each. In fact you should design your circuit to stay comfortably under 30mA per pin.

I can smell burning. Can anyone else smell it?

Oh yes!

The MAX7219s - and modules using them - are so cheap and easily available on eBay, that it is simply absurd to try and use port pins which simply do not have an adequate current carrying capacity, or waste time assembling ridiculous numbers of transistors.

And it performs the multiplexing for you - you merely write the data to it and do not need to access it again until you want to change the pattern. And just three pins will control 8 by 8, 16 by 8, 24 by 8, 32 by 8, etc.

Why would you do it any other way?

Because i dont have them currently and dont want to wait another 1/2 moths. I waited 2 months to get the matrixes itself and i dont intend to go trough all that again. Should have asked what i did in this thread much sooner, but i did it now using npn transistors on common anodes and common cathodes and everything works. I alread programmed so that the matrixes can show 8×16-64 "picture". I am currently working on making tetris and everything is actually going better than expected, its just kinda hard doing the project as i have to study and cant concentrate fully between the weekends but its going great nontheless. I will try doing it with max 7219 when i get it but currently everything is going great thank you all for answers!

If you only power one LED at a time, you will be fine.
You use 16 pins for your 8x8.
How fast you scan will determine how much flicker.
Also, it will not be real bright but enough to see.
As was stated, using a chip designed to do it is better.
If all but one pin are at the opposite level at any one time,
only one led will light.
Order the 7219 and in the mean time, play with the display.