8X8 led matrix program works Why?

I was messing around with a program, I got to work the way I want, but don’t understand why, To me both col and row should increase at the same time.

  #include "LedControl.h"
LedControl lc = LedControl(12, 11, 10, 1);

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0,1);
  lc.clearDisplay(0);// clear screen
}


void loop()
{
  for (int row = 0; row < 8; row++)
  for (int col = 0; col < 8; col++)
  {
    
    {
      lc.setLed(0, row, col, true);
      delay (250);
    }
  }
}

This will run one LED at a time.

Print to Serial Monitor, and you will see what is incrementing and what isn’t.

Your code should be written as:

for (int row = 0; row < 8; row++)
{
  for (int col = 0; col < 8; col++)
  {
      lc.setLed(0, row, col, true);
      delay (250);
  }
}

Tried change in program but the result is the same, one led at a time. Back to my original question. Why? Both row and col should increase together.

#include "LedControl.h"
LedControl lc = LedControl(12, 11, 10, 1);

void setup() {
  lc.shutdown(0, false);
  lc.setIntensity(0, 1);
  lc.clearDisplay(0);// clear screen
  Serial.begin(9600);
}


void loop()
{
  for (int row = 0; row < 8; row++)
  {
    for (int col = 0; col < 8; col++)
    {
      lc.setLed(0, row, col, true);
      Serial.print("Row, ");
      Serial.print(row);
      Serial.print(" col, ");
      Serial.println(col);
      delay (250);
    }
  }
}

Both row and col should increase together.

Is that what you want to happen but can't figure out how to change the code?

Or is that what you believe the code should do but isn't?

If the latter, you are just plain wrong. The code is doing exactly what it says on the tin.

Did you follow the advice given? It was intended to teach you why what is happening is happening and in fact is exactly what you should expect to happen.

This link might help, it shows you what should happen with a matrix scan:- http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

In your code you have what is called "nested loops", only one thing col or row will change at once. To start with row is set to 0, then col goes through all the values between 0 and 7. Then row is set to 1, then col goes through all the values between 0 and 7. This repeats until row is set to 7, then col goes through all the values between 0 and 7. Then row goes back to being 0.

Edit:- Your code is not the normal way to drive a LED matrix.

but the result is the same, one led at a time.

Yes that is what the code is written to do.