Hi,
this is how the code looks now: much cleaner and Ram-saving ![]()
Thanks very much ![]()
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);
  }
}
}