# 8X8 Led Matrix: Code and Setup Query

Hi,

I'm currently trying to learn about LED matices. I have successfully wired up a 8x8 matrix (preassembled), but the code is confusing me. Does anyone know what the bare basic code is to light one led (e.g. top left, A:1)? No fancy stuff, just the first LED on.

Also, does it really matter which pins I have connected to which rod? Like a shift register has pins like VCC, GND, lhtcp etc. which have to go to their own respective pins. In my current matrix circuit, I have analogue pins going in the bottom of the matrix. Do the analog pins have to go specifically into these matrix pins? Or can I wire up the arduino in a pin 1 to matrix pin 1 (bottom left) fashion till there are no pins left on the matrix.

Does it matter which pins the resistors are connected to?

I'm also assuming the bottom pins of the matrix are the rows?

Thanks

Does this help?

Kadoodle: Does anyone know what the bare basic code is to light one led (e.g. top left, A:1)? No fancy stuff, just the first LED on.

``````pinMode(RowAPin, OUTPUT);
pinMode(Column1Pin, OUTPUT);
// Either
digitalWrite(RowAPin, HIGH); // Row Anode
digitalWrite(Column1Pin, LOW)  // Column Cathode
// Or
digitalWrite(RowAPin, LOW);  // Row Cathode
digitalWrite(Column1Pin, HIGH)  // Column Anode
``````

Kadoodle: Also, does it really matter which pins I have connected to which rod? Like a shift register has pins like VCC, GND, lhtcp etc. which have to go to their own respective pins. In my current matrix circuit, I have analogue pins going in the bottom of the matrix. Do the analog pins have to go specifically into these matrix pins? Or can I wire up the arduino in a pin 1 to matrix pin 1 (bottom left) fashion till there are no pins left on the matrix.

You can use the data pins in any order as long as your sketch is written to use the right pin number for each signal.

Kadoodle: Does it matter which pins the resistors are connected to?

Yes. If you light one row at a time the resistors have to be on the column lines. If you light one column at a time the resistors have to be on the row pins. The common pins carry more current and therefore can't usually be connected directly to the Arduino pins. Using the Cathode pins for the common pins allows you to use cheap NPN transistors for the current handling.

Kadoodle: I'm also assuming the bottom pins of the matrix are the rows?

Depends on the matrix and how you orient it. Turn it 90 degrees to change 'rows' into 'columns'. More important is Anodes (+) and Cathodes (-).