Very simple 3x3x3 cube sketch

That is essentially an oxymoron!

A MAX7219 would take the 27 LEDs, one resistor and two capacitors, all bar the LEDs are available ready mounted on a cheap module. The code is massively simplified.

Similarly, you need to comprehend that such things as "for" loops make code much simpler and more comprehensible.

If - of course - properly written. :grin: