LED Dot Matrix

This code is for an 8X8 matrix I have an 7x5 how would I change the code to make it work?
This is my first multiplexing project so i dont quite understand it quite yet.

#include <TimerOne.h>
//Pin connected to Pin
int latchPin = 8; //Pin connected to Pin 8 latch 74HC595 (Latch) 
int clockPin = 12; //Pin connected to Pin 12 of 74HC595 (Clock)
int dataPin = 11;//Pin connected to Pin 11 of 74HC595 (Data) 
uint8_t led[8]; 
long counter1 = 0; 
long counter2 = 0;


14 of 74HC595 (Data)
//set pins to output 
void setup() {  
  pinMode(latchPin, OUTPUT); 
  pinMode(clockPin, OUTPUT); 
  pinMode(dataPin, OUTPUT); 
  led[0] = B11111111; 
  led[1] = B1000001; 
  led[2] = B10111101; 
  led[3] = B10100101; 
  led[4] = B10100101; 
  led[5] = B10111101; 
  led[6] = B10000001; 
  led[7] = B11111111; 
  Timer1.initialize(10000);
  Timer1.attachInterrupt(screenUpdate);
}
void loop() { 
  counter1++;
  if (counter1 >=100000) {
    counter2++;
  } 
  if (counter2 >= 10000) {
    counter1 = 0; 
    counter2 = 0; 
    for (int i=0; i<8; i++) {
      led[i]= ~led[i];
    } 
  }
  void screenUpdate() { 
    uint8_t row = B00000001;
    for (byte k = 0; k < 9; k++) { 
      // Open up the latch ready to receive data
      !	digitalWrite(latchPin, LOW); 
      shiftIt(~row );
      shiftIt(led[k] ); // LED array

      // Close the latch, sending the data in the registers out to the matrix

      digitalWrite(latchPin, HIGH);	
      row = row << 1; 
    }
  }
  void shiftIt(byte dataOut) { // Shift out 8 bits LSB first, // on rising edge of clock
  }
  boolean pinState; //clear shift register read for sending data
  digitalWrite(dataPin, LOW);
  // for each bit in dataOut send out a bit
  for (int i=0; i<8; i++) { //set clockPin to LOW prior to sending bit
  }
  digitalWrite(clockPin, LOW);
  // 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); //send bit out on rising edge of clock 
  digitalWrite(clockPin, HIGH);
  digitalWrite(dataPin, LOW);
} 
}
//stop shifting
digitalWrite(clockPin, LOW);

}

There is one element in the array for each row. You have fewer rows, so you need fewer elements.

In each element, there is one bit per column.

This code is for an 8X8 matrix

That code won't even compile.

You seem to have lost something in listing here:

long counter2 = 0;

// missing some variable definitions, and pinouts for the 2nd shift register??

14 of 74HC595 (Data)
//set pins to output

I think it should work as is; you just won’t have the 8th and 6-7-8th LEDs to turn on.

Or, you could probably reduce this by 1 (assuming this is the height):
for (byte k = 0; k < 9; k++) {

and this by 3 (assuming this is the width):
for (int i=0; i<8; i++) { //set clockPin to LOW prior to sending bit

Or, reverse those if the orientation is swapped.

Sorry that it didn’t compile I still had a few errors in it but it compiles now

#include <TimerOne.h>
int latchPin = 8; //Pin connected to Pin 8 latch 74HC595 (Latch) 
int clockPin = 12; //Pin connected to Pin 12 of 74HC595 (Clock)
int dataPin = 11;//Pin connected to Pin 11 of 74HC595 (Data) 

uint8_t led[8]; 
long counter1 = 0; 
long counter2 = 0;

//set pins to output 
void setup() 
{  
  pinMode(latchPin, OUTPUT); 
  pinMode(clockPin, OUTPUT); 
  pinMode(dataPin, OUTPUT); 
  led[0] = B11111111; 
  led[1] = B1000001; 
  led[2] = B10111101; 
  led[3] = B10100101; 
  led[4] = B10100101; 
  led[5] = B10111101; 
  led[6] = B10000001; 
  led[7] = B11111111; 
  Timer1.initialize(10000);
  Timer1.attachInterrupt(screenUpdate);
}
void loop() { 
  counter1++;
  if (counter1 >=100000) {
    counter2++;
  } 
  if (counter2 >= 10000) {
    counter1 = 0; 
    counter2 = 0; 
    for (int i=0; i<7; i++) {
      led[i]= ~led[i];
    } 
  }
}
void screenUpdate() { 
  uint8_t row = B00000001;
  for (byte k = 0; k < 8; k++) { 
    // Open up the latch ready to receive data
   digitalWrite(latchPin, LOW); 
    shiftIt(~row );
    shiftIt(led[k] ); // LED array
    // Close the latch, sending the data in the registers out to the matrix
    digitalWrite(latchPin, HIGH);	row = row << 1; 
  }
}
void shiftIt(byte dataOut) { 
  // Shift out 8 bits LSB first, 
  // on rising edge of clock
  
  boolean pinState; 
  
  //clear shift register read for sending data
  digitalWrite(dataPin, LOW);
  
  // for each bit in dataOut send out a bit
  for (int i=0; i<8; i++) { 
    //set clockPin to LOW prior to sending bit

    digitalWrite(clockPin, LOW);

    // 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); 
    //send bit out on rising edge of clock 
    digitalWrite(clockPin, HIGH); 
    digitalWrite(dataPin, LOW);
  }
  //stop shifting
  digitalWrite(clockPin, LOW);
}

Ok, how is the matrix connected up?
I can see the shift register being connected to the anodes, what is the connection to the cathodes? (or the other way around)
I was thinking 2 shift registers, one controlling which row was 'enabled' while the other turned on selected LEDs,
advancing to the next row & selected LEDs, etc.
I don't understand the connections behind this code, especially when things are defined the same in this array:

led[0] = B11111111;
led[7] = B11111111;

led[1] = B1000001; // missing a 0? only 7 bits here
led[6] = B10000001;

led[2] = B10111101;
led[5] = B10111101;

led[3] = B10100101;
led[4] = B10100101;