Help with understanding this multiplexing code for an 8x8 dot matrix display

Hey again everyone. I could have put this in a previous post however my question is slightly different to the last. Im going to put the entire code below but I’m only confused with one thing…

#include <TimerOne.h>
int latchPin = 8; //Pin connected to Pin 12 of 74HC595 (Latch)
int clockPin = 12; //Pin connected to Pin 11 of 74HC595 (Clock)
int dataPin = 11; //Pin connected to Pin 14 of 74HC595 (Data)
byte led[8]; // 8 element unsigned integer array to store the sprite

void setup() {
pinMode(latchPin, OUTPUT); // set the 3 digital pins to outputs
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
led[0] = B11111111; // enter the binary representation of the image
led[1] = B10000001; // into the array
led[2] = B10111101;
led[3] = B10100101;
led[4] = B10100101;
led[5] = B10111101;
led[6] = B10000001;
led[7] = B11111111;
// set a timer of length 10000 microseconds (1/100th of a second)
Timer1.initialize(10000);
// attach the screenUpdate function to the interrupt timer
Timer1.attachInterrupt(screenUpdate);
}
void loop() {
for (int i=0; i<8; i++) {
led[i]= ~led[i]; // invert each row of the binary image
}
delay(500);
}
void screenUpdate() { // function to display image
byte row = B10000000; // row 1
for (byte k = 0; k < 8; k++) {
digitalWrite(latchPin, LOW); // open latch ready to receive data
shiftIt(~led[k] ); // shift out the LED array (inverted)
shiftIt(row ); // shift out row binary number
// Close the latch, sending the data in the registers out to the matrix
digitalWrite(latchPin, HIGH);
row = row >> 1; // bitshift right
}
}
void shiftIt(byte dataOut) { // Shift out 8 bits LSB first, on rising edge of clock
boolean pinState;
digitalWrite(dataPin, LOW); //clear shift register read for sending data
for (int i=0; i<8; i++) { // for each bit in dataOut send out a bit
digitalWrite(clockPin, LOW); //set clockPin to LOW prior to sending bit
// if the value of DataOut and (logical AND) a bitmask
// are true, set pinState to 1 (HIGH)
if ( dataOut & (1<<i) ) {
pinState = HIGH;
}

else {
pinState = LOW;
}
//sets dataPin to HIGH or LOW depending on pinState
digitalWrite(dataPin, pinState);
digitalWrite(clockPin, HIGH); //send bit out on rising edge of clock
digitalWrite(dataPin, LOW);
}
digitalWrite(clockPin, LOW); //stop shifting
}

What I do not get is the need for row. From what I gather, B10000000 represents the first row on the 8x8 led dot matrix display, and say B00000100 would be the 6th row. First of all, I dont understand how that binary number represents the row.

From what I was thinking, the function shiftIt(led[k]) (with the not symbol) set each pinState to either a HIGH or al LOW so that the image could be conveyed. I can’t get my head around calling the same function and passing the row as a parameter…Thank you for reading and hopefully you can help me understand it correctly!

Binary numbers are made up of strings of bits. The numbers you are using have 8 bits. Each bit can have the value 0 or 1.

If you had 8 shift registers with 8 bits each you could just send out the eight rows of image and be done. There would be one output for each LED.

By having the LED's in a matrix you can save money by driving them with just two shift registers. You can only light one row at a time so yo give the illusion of a full picture you draw each row in turn and repeat rapidly enough that it looks like the LED's you are blinking are on all the time. One of the shift registers has a single bit turned on which selects which row is being lit. The second shift register contains the pattern of lights for that row.

From what I gather, B10000000 represents the first row on the 8x8 led dot matrix display, and say B00000100 would be the 6th row. First of all, I dont understand how that binary number represents the row.

Bits are numbered from right to left. In B10000000, only the 7th bit is set. In B00000100, only the 3rd bit is set. The 0th bit would indicate the bottom row. The 1st bit would indicate the next row up. This continues until the 7th bit indicates the top row.

Ah brilliant, that makes sense now! Thank you to both of you :)