Performance Issue probably run out of Ram

Hi,

this is how the code looks now: much cleaner and Ram-saving :slight_smile:
Thanks very much :stuck_out_tongue:
Any further improvements?

// Start ligtUpLeds function

void lightUpLeds(){

int bytesToShift[4];


for(int i = 0; i < 10000; i++)  
for (int row = 0; row < 8; row++)
{
    for (int a = 0; a < 4; a++)
        bytesToShift[a] = 255;

    for (int matrixNumber = 0; matrixNumber < totalNumberOfMatrices; matrixNumber++)
        for (int possibleLed = 0; possibleLed < 8; possibleLed++)
            if (drawLeds[matrixNumber][possibleLed][row] == true)
              bytesToShift[matrixNumber] -= (255 - bytesX[matrixNumber][possibleLed]);
              
    if (bytesToShift[0] != 255 || bytesToShift[1] != 255 || bytesToShift[2] != 255 || bytesToShift[3] != 255)
    {
        digitalWrite(latchPin, LOW);
        for (int matrixToDisplay = (totalNumberOfMatrices - 1); matrixToDisplay > -1; matrixToDisplay--)
        {            
            if (matrixToDisplay % 2 == 0)
            {
              //Serial.println(bytesToShift[matrixToDisplay]);
              //Serial.println(bytesY[matrixToDisplay][row]);
                shiftOut(dataPin, clockPin, MSBFIRST, bytesToShift[matrixToDisplay]);
                shiftOut(dataPin, clockPin, MSBFIRST, bytesY[matrixToDisplay][row]);
            }
            else
            {  
              //Serial.println(bytesY[matrixToDisplay][row]);
              //Serial.println(bytesToShift[matrixToDisplay]);
                shiftOut(dataPin, clockPin, MSBFIRST, bytesY[matrixToDisplay][row]);
                shiftOut(dataPin, clockPin, MSBFIRST, bytesToShift[matrixToDisplay]);                            
            }    
        } 
        digitalWrite(latchPin, HIGH);
        delay(1);
    }

}


}