different errors that arose when making 3x3x3 white LED cube

Hello,

I recently made a 3x3x3 LED cube using white LEDs using the instructions on

I faced a couple of problems and now I have to do a workshop related to it so I need to know why those errors occurred.
I have attached the code to the post.

  1. As you can see in the code, in order to power an led I have to do DigitalWrite(layer, HIGH) and then DigitalWrite(column, LOW)
    My question is that normally we would have to do DigitalWrite(column, high). I figured out the code through trial and error. Is it because the anodes and cathodes got switched? I tried to do according to the schematic on the website, columns have common anodes and layers have common cathodes.

  2. when applying this code, if I want to light up the entire cube (the first line pattern in the code), the brightness of the led decreases. Is this because I didn't use a transistor? I powered it using the USB port in my laptop(5V). Or is this because we used only 3 resistors of 2220 ohms.

  3. is it necessary to use a transistor in a 3x3x3 LED cube?

  4. Should the resistors be connected to each layer or each of the columns?

  5. I want to be able to switch only one LED in the entire cube. What would be the code to do that?

I added the code below because it wouldn't attach for some reason.

void setup() {
int d=100;
   pinMode(2, OUTPUT); 
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT); 
  pinMode(5, OUTPUT); 
  pinMode(6, OUTPUT); 
  pinMode(7, OUTPUT); 
  pinMode(8, OUTPUT); 
   pinMode(9, OUTPUT); 
   pinMode(10, OUTPUT); 
   pinMode(A0, OUTPUT); 
   pinMode(A1, OUTPUT); 
   pinMode(A2, OUTPUT); 

    }  


void loop() {
   
digitalWrite(A2, HIGH);
digitalWrite(A1, HIGH);    // lights up entire cube
digitalWrite(A0, HIGH);
    
digitalWrite(2,LOW);
delay(d);
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
delay(d);                     // snake column wise
digitalWrite(3, HIGH);
digitalWrite(4,LOW);
delay(d);
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
delay(d);
digitalWrite(7,HIGH);
digitalWrite(6,LOW);
delay(d);
digitalWrite(6,HIGH);
digitalWrite(5,LOW);
delay(d);
digitalWrite(5,HIGH);
digitalWrite(8,LOW);
delay(d);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
delay(d);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
delay(200);

digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(d);                     // snake column wise rewind
digitalWrite(9, HIGH);
digitalWrite(8,LOW);
delay(d);
digitalWrite(8,HIGH);
digitalWrite(5,LOW);
delay(d);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
delay(d);
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
delay(d);
digitalWrite(7,HIGH);
digitalWrite(4,LOW);
delay(d);
digitalWrite(4,HIGH);
digitalWrite(3,LOW);
delay(d);
digitalWrite(3,HIGH);
digitalWrite(2,LOW);
delay(200);



digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);

digitalWrite(A2, HIGH);
digitalWrite(2,LOW);
delay(d);
digitalWrite(2,HIGH);
digitalWrite(5,LOW);
delay(d);                     // snake pin wise top layer
digitalWrite(5, HIGH);
digitalWrite(8,LOW);
delay(d);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
delay(d);
digitalWrite(9,HIGH);
digitalWrite(6,LOW);
delay(d);
digitalWrite(6,HIGH);
digitalWrite(3,LOW);
delay(d);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
delay(d);
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
delay(d);
digitalWrite(7,HIGH);
digitalWrite(10,LOW);
delay(d);
digitalWrite(10,HIGH);


digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);

digitalWrite(A1, HIGH);
digitalWrite(10,LOW);
delay(d);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
delay(d);                     // snake pin wise middle layer
digitalWrite(9, HIGH);
digitalWrite(8,LOW);
delay(d);
digitalWrite(8,HIGH);
digitalWrite(5,LOW);
delay(d);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
delay(d);
digitalWrite(6,HIGH);
digvitalWrite(7,LOW);
delay(d);
digitalWrite(7,HIGH);
digitalWrite(4,LOW);
delay(d);
digitalWrite(4,HIGH);
digitalWrite(3,LOW);
delay(d);
digitalWrite(3,HIGH);
digitalWrite(2,LOW);
delay(d);
digitalWrite(2,HIGH);


digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);

digitalWrite(A0, HIGH);
digitalWrite(2,LOW);
delay(d);
digitalWrite(2,HIGH);
digitalWrite(5,LOW);
delay(d);                     // snake pin wise bottom layer
digitalWrite(5, HIGH);
digitalWrite(8,LOW);
delay(d);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
delay(d);
digitalWrite(9,HIGH);
digitalWrite(6,LOW);
delay(d);
digitalWrite(6,HIGH);
digitalWrite(3,LOW);
delay(d);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
delay(d);
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
delay(d);
digitalWrite(7,HIGH);
digitalWrite(10,LOW);
delay(d);
digitalWrite(10,HIGH);

delay(200);

Well, I suppose you realise by now that design is dodgy (faulty).

For a start, the resistors are wrong - you should have nine resistors in the column wires not three in the rows (levels), and they should be at least 1k. This will bring the LED current down to 3 mA each and 27 mA for the whole nine lit simultaneously with which the pin driver can cope - given that you are multiplexing one row at a time. If you try to illuminate the whole lot at once - activating all rows together, then you will be sharing that 3 mA among three rows, but the effect will be (almost) the same as multiplexing one row after another.

If you really want to build a single colour 4 by 4 cube, you should use one of the readily available MAX7219 modules which is designed to multiplex 64 LEDs with good and uniform brightness.


Now, You need to go and read the forum instructions so that you can go back and modify your original post - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output) from the IDE and click the icon. In fact, the IDE has a "copy for forum" link to put these markings on to a highlighted block for you so you then just paste it here in a posting window.

It is inappropriate to attach it as a ".ino" file. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And that would also assume they are using a PC and have the IDE running on that PC.

But don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. If you do not post it as "code", it can be quite garbled and is always more difficult to read.

Yeah, the resistor positions are not ideal but for basic testing will tell you if you're on the right track.

You need to multiplex this sort of display. That means rapidly cycling through the layer "commons" and turning on the LEDs on each layer at the right time. This happens at a rate that meets the "persistence of vision" criteria; for this sort of thing, going through all 3 layers in ~20-30mS should give that effect.

By using muxing, addressing a single LED in the matrix is easy. If you don't mux, the cube's usefulness is severely compromised.

I modified your code to support multiplexing. I didn't feel like transcribing your patterns so I made a simple "walk an LED through the matrix" pattern. You can make anything you like.

It's somewhat more complex than your code and may not work out of the gate.

const unsigned long CUBE_DELAY_SHORT = 100;     //mS
const unsigned long CUBE_DELAY_LONG = 200;      //mS

//assumes each panel is wired like this (view from top)
// 2 3 4
// 5 6 7
// 8 9 A

#define NUM_PATTERNS    28      //27 LEDs plus all off

//local prototypes
void SetPlane( byte );
void DriveLEDMatrix( void );
void UpdatePlaneVars( void );

const int LAYER_0 = A0;
const int LAYER_1 = A1;
const int LAYER_2 = A2;

#define NUM_LEDS_PER_PLANE      9
#define COL_UPDT_RATE           10  //mS per layer
#define LAY_0                   0
#define LAY_1                   1
#define LAY_2                   2

#define LAYER_ON                HIGH
#define LAYER_OFF               LOW
#define LED_OFF                 HIGH    //with common anode
#define LED_ON                  LOW

struct patternStruct
{
    int Plane_2;
    int Plane_1;
    int Plane_0;
};

typedef struct patternStruct Patterns;

Patterns LEDPatterns[NUM_PATTERNS] =
    {
        {0x0000, 0x0000, 0x0001},
        {0x0000, 0x0000, 0x0002},
        {0x0000, 0x0000, 0x0004},
        {0x0000, 0x0000, 0x0008},
        {0x0000, 0x0000, 0x0010},
        {0x0000, 0x0000, 0x0020},
        {0x0000, 0x0000, 0x0040},
        {0x0000, 0x0000, 0x0080},
        {0x0000, 0x0000, 0x0100},
        {0x0000, 0x0001, 0x0000},
        {0x0000, 0x0002, 0x0000},
        {0x0000, 0x0004, 0x0000},
        {0x0000, 0x0008, 0x0000},
        {0x0000, 0x0010, 0x0000},
        {0x0000, 0x0020, 0x0000},
        {0x0000, 0x0040, 0x0000},
        {0x0000, 0x0080, 0x0000},
        {0x0000, 0x0100, 0x0000},
        {0x0001, 0x0000, 0x0000},
        {0x0002, 0x0000, 0x0000},
        {0x0004, 0x0000, 0x0000},
        {0x0008, 0x0000, 0x0000},
        {0x0010, 0x0000, 0x0000},
        {0x0020, 0x0000, 0x0000},
        {0x0040, 0x0000, 0x0000},
        {0x0080, 0x0000, 0x0000},
        {0x0100, 0x0000, 0x0000},
        {0x0000, 0x0000, 0x0000}    //all LEDs off
    };

byte
    stateMatrix;

int
    DispPlane_0,
    DispPlane_1,
    DispPlane_2;

int
    pinPlaneLED[NUM_LEDS_PER_PLANE] = 
    {
        2, 3, 4, 5, 6, 7, 8, 9, 10
    };
    
void setup() 
{
    for( int i=0; i<NUM_LEDS_PER_PLANE; i++ )
    {
        pinMode( 2+i, OUTPUT);
        digitalWrite( 2+i, LED_OFF );
        
    }//for
    
    pinMode(A0, OUTPUT);
    digitalWrite( A0, LAYER_OFF );
    pinMode(A1, OUTPUT);
    digitalWrite( A1, LAYER_OFF );
    pinMode(A2, OUTPUT);
    digitalWrite( A2, LAYER_OFF );
    
    stateMatrix = LAY_0;

}//setup

void DriveLEDMatrix( void )
{
    static unsigned long
        timeMatrix = 0;
    unsigned long
        timeNow;

    timeNow = millis();
    if( (timeNow - timeMatrix) < COL_UPDT_RATE )
        return;

    timeMatrix = timeNow;

    switch( stateMatrix )
    {
        case    LAY_0:
            digitalWrite(LAYER_0, LAYER_ON);
            digitalWrite(LAYER_1, LAYER_OFF);
            digitalWrite(LAYER_2, LAYER_OFF);
            stateMatrix = LAY_1;
            
        break;
        case    LAY_1:
            digitalWrite(LAYER_0, LAYER_OFF);
            digitalWrite(LAYER_1, LAYER_ON);
            digitalWrite(LAYER_2, LAYER_OFF);
            stateMatrix = LAY_2;
        break;
        case    LAY_2:
            digitalWrite(LAYER_0, LAYER_OFF);
            digitalWrite(LAYER_1, LAYER_OFF);
            digitalWrite(LAYER_2, LAYER_ON);
            stateMatrix = LAY_0;
        break;
            
    }//switch

    SetPlane( stateMatrix );
    
}//DriveLEDMatrix

//called from within the matrix drive code, this
//sets the LEDs for the current layer
void SetPlane( byte stateMatrix )
{
    int
        i,
        mask,
        Plane;
        
    switch( stateMatrix )
    {
        case    LAY_0:
            Plane = DispPlane_0;
        break;

        case    LAY_1:
            Plane = DispPlane_1;
        break;

        case    LAY_2:
            Plane = DispPlane_2;
        break;
    }//

    //Plane LEDs are expressed as bits within an int (2 bytes):
    //0bxxxxxxx000000000
    //         098765432
    //         1
    //the upper bits are not-care (x)
    //the logic below walks through the variable holding the pattern for 
    //  the current panel and turns on/off the LEDs as required 
    mask = 0x0001;
    for( i=0; i<NUM_LEDS_PER_PLANE; i++ )
    {
        digitalWrite( pinPlaneLED[i], (Plane & mask) ? LED_ON:LED_OFF );
        mask << 1;
                 
    }//for
    
}//SetPlane


void UpdatePlaneVars( void )
{
    static int
        planeIndex = 0;
    static unsigned long
        timeDelay = 0,
        timePlane = 0;
    unsigned long
        timeNow;

    timeNow = millis();
    if( ( timeNow - timePlane) < timeDelay )
        return;

    timePlane = timeNow;

    DispPlane_0 = LEDPatterns[planeIndex].Plane_0;
    DispPlane_1 = LEDPatterns[planeIndex].Plane_1;
    DispPlane_2 = LEDPatterns[planeIndex].Plane_2;
    
    planeIndex++;
    if( planeIndex == NUM_PATTERNS )
    {
        planeIndex = 0;
        timeDelay = CUBE_DELAY_LONG;
    }
    else
        timeDelay = CUBE_DELAY_SHORT;
        
}//UpdatePlaneVars

void loop() 
{
    DriveLEDMatrix();
    UpdatePlaneVars();
    
}//loop

Do you think you are going to provide any sort of valuable educational experance presenting a workshop of a faulty design, with you knowing so little about it and with such very bad software?

It seems to me that the trouble with the maker movement at the moment is that anyone who can get an LED to blink thinks they are qualified to teach others.

I think you are saying what I was saying, but were you addressing it to the OP or "Blackfin"?

void setup() {
int d=100;

Oops

(And also suggests the code is incomplete)

I didn't follow that - but in any case I am waiting for some response from the OP.

Paul__B:
I think you are saying what I was saying, but were you addressing it to the OP or "Blackfin"?

?

Paul__B:
I didn't follow that - but in any case I am waiting for some response from the OP.

'd' isn't used in setup(), but is used in loop().
loop() has no definition for a variable called 'd'

First of all, thank you everyone for reply.

Grumpy_Mike:
Do you think you are going to provide any sort of valuable educational experance presenting a workshop of a faulty design, with you knowing so little about it and with such very bad software?

It seems to me that the trouble with the maker movement at the moment is that anyone who can get an LED to blink thinks they are qualified to teach others.

To answer your question, I will merely be assisting the workshop. A more qualified person will be the one in charge. Andthought I should get my errors cleared. And no. Now I won't be using this design. But thank you for your valuable advice

nsivakumar:
Now I won't be using this design. But thank you for your valuable advice

+1 Karma

If you want to continue the project for your own education, we will be happy to help. Now we know you won't be spreading bad practices, I'm sure we will be more supportive.

So does anybody have any recommendations like any website/book that has good coding information/guides so I can learn how to code an LED cube the right way?

I think it would be a mistake to focus only on the coding. Please post your schematic. A schematic you have made. Because with most Arduino projects, half the story is the circuit and half is the code.

nsivakumar:
So does anybody have any recommendations like any website/book that has good coding information/guides so I can learn how to code an LED cube the right way?

Did you have a look a the code I posted earlier?

Blackfin:
Did you have a look a the code I posted earlier?

Yes, I did and as you said, the code is too complex for me to understand.

PaulRB:
I think it would be a mistake to focus only on the coding. Please post your schematic. A schematic you have made. Because with most Arduino projects, half the story is the circuit and half is the code.

I have attached a rough schematic, I apologize for the untidiness.

Swap the E and C connections on the transistors and reduce the base resistors to ~1K.

thank you. But apart from that is the schematic alright?

Also, do you have any recommendations for a reliable source to learn to code for Arduino or at least coding related to an led cube for now?

Is this your first coding attempt? If so, it's pretty ambitious.

I've changed my code a bit and added commenting. Have a look at it and see if it makes sense:

const unsigned long CUBE_DELAY_SHORT = 100;     //mS
const unsigned long CUBE_DELAY_LONG = 200;      //mS

//assumes each panel is wired like this (view from top)
// 2 3 4
// 5 6 7
// 8 9 A

#define NUM_PATTERNS    28      //27 LEDs plus all off

//local prototypes
void SetPlane( byte );
void DriveLEDMatrix( void );
void UpdatePlaneVars( void );

const int LAYER_0 = A0;
const int LAYER_1 = A1;
const int LAYER_2 = A2;

#define NUM_LEDS_PER_PLANE      9   //number of LEDs per plane
#define COL_UPDT_RATE           10  //the period of LED layer switching

//defines for the layer selection state machine
#define LAY_0                   0
#define LAY_1                   1
#define LAY_2                   2

//output senses to turn LEDs on and off in conjunction with layer control
#define LAYER_ON                HIGH    //a high turns on the NPN transistor grounding the cathodes of each layer
#define LAYER_OFF               LOW
#define LED_ON                  HIGH    //a high supplies current to the LED anodes
#define LED_OFF                 LOW

//structure holding the LED bit patterns for a bit of an animation
struct patternStruct
{
    int Plane_2;
    int Plane_1;
    int Plane_0;
};

typedef struct patternStruct Patterns;

//bit patterns for display
//left to right is plane 2, then 1 and then 0 (I used plane and layer interchangeably in the code)
//a '1' turns corresponds to an LED on
//Plane LEDs are expressed as bits within an int (2 bytes):
//0bxxxxxxx000000000
//         098765432
//         1
//the upper bits are not-care (x)
//the logic below walks through the variable holding the pattern for 
//  the current panel and turns on/off the LEDs as required 
Patterns LEDPatterns[NUM_PATTERNS] =
    {
        {0x0000, 0x0000, 0x0001},
        {0x0000, 0x0000, 0x0002},
        {0x0000, 0x0000, 0x0004},
        {0x0000, 0x0000, 0x0008},
        {0x0000, 0x0000, 0x0010},
        {0x0000, 0x0000, 0x0020},
        {0x0000, 0x0000, 0x0040},
        {0x0000, 0x0000, 0x0080},
        {0x0000, 0x0000, 0x0100},
        {0x0000, 0x0001, 0x0000},
        {0x0000, 0x0002, 0x0000},
        {0x0000, 0x0004, 0x0000},
        {0x0000, 0x0008, 0x0000},
        {0x0000, 0x0010, 0x0000},
        {0x0000, 0x0020, 0x0000},
        {0x0000, 0x0040, 0x0000},
        {0x0000, 0x0080, 0x0000},
        {0x0000, 0x0100, 0x0000},
        {0x0001, 0x0000, 0x0000},
        {0x0002, 0x0000, 0x0000},
        {0x0004, 0x0000, 0x0000},
        {0x0008, 0x0000, 0x0000},
        {0x0010, 0x0000, 0x0000},
        {0x0020, 0x0000, 0x0000},
        {0x0040, 0x0000, 0x0000},
        {0x0080, 0x0000, 0x0000},
        {0x0100, 0x0000, 0x0000},
        {0x0000, 0x0000, 0x0000}    //all LEDs off
    };

byte
    stateMatrix;

//used for display; supplied from the table above
int
    DispPlane_0,
    DispPlane_1,
    DispPlane_2;

//identifies the Arduino pin numbers associated with each LED layer
int
    pinPlaneLED[NUM_LEDS_PER_PLANE] = 
    {
        2, 3, 4, 5, 6, 7, 8, 9, 10
    };
    
void setup() 
{
    //set the 9 LED outputs and turn them "off"
    for( int i=0; i<NUM_LEDS_PER_PLANE; i++ )
    {
        pinMode( 2+i, OUTPUT);
        digitalWrite( 2+i, LED_OFF );
        
    }//for

    //set up the layer controls and turn them "off" too
    pinMode(A0, OUTPUT);
    digitalWrite( A0, LAYER_OFF );
    pinMode(A1, OUTPUT);
    digitalWrite( A1, LAYER_OFF );
    pinMode(A2, OUTPUT);
    digitalWrite( A2, LAYER_OFF );

    //initialize the layer state machine to layer 0
    stateMatrix = LAY_0;

}//setup

////////////////////////////////////////////////////////////////////////////////////////////////////
// DriveMatrix
//  cycles through the layers every COL_UPDT_RATE mS
//  turns off the LEDs before switching and applies new pattern after switching
////////////////////////////////////////////////////////////////////////////////////////////////////
void DriveLEDMatrix( void )
{
    byte
        lastState;
    static unsigned long
        timeMatrix = 0;
    unsigned long
        timeNow;

    //time for an update?
    timeNow = millis();
    if( (timeNow - timeMatrix) < COL_UPDT_RATE )
        return;

    //reset timer
    timeMatrix = timeNow;

    //turn off LEDs on current layer
    ClearOutputs();
    
    //apply new LED pattern
    SetPlane( stateMatrix );
    
    //switch layers
    switch( stateMatrix )
    {
        case    LAY_0:
            digitalWrite(LAYER_0, LAYER_ON);
            digitalWrite(LAYER_1, LAYER_OFF);
            digitalWrite(LAYER_2, LAYER_OFF);
            stateMatrix = LAY_1;    //next layer to be applied next pass
            
        break;
        case    LAY_1:
            digitalWrite(LAYER_0, LAYER_OFF);
            digitalWrite(LAYER_1, LAYER_ON);
            digitalWrite(LAYER_2, LAYER_OFF);
            stateMatrix = LAY_2;    //next layer to be applied next pass
        break;
        case    LAY_2:
            digitalWrite(LAYER_0, LAYER_OFF);
            digitalWrite(LAYER_1, LAYER_OFF);
            digitalWrite(LAYER_2, LAYER_ON);
            stateMatrix = LAY_0;    //next layer to be applied next pass
        break;
            
    }//switch
    
}//DriveLEDMatrix

void ClearOutputs( void )
{
    int
        i;

    //run through the output pins and turn them "off"
    for( i=0; i<NUM_LEDS_PER_PLANE; i++ )
        digitalWrite( 2+i, LED_OFF );

}//ClearOutputs

//called from within the matrix drive code, this
//sets the LEDs for the current layer
void SetPlane( byte stateMatrix )
{
    int
        i,
        mask,
        Plane;

    //find out which layer's variable we need to apply
    switch( stateMatrix )
    {
        case    LAY_0:
            //layer 0
            Plane = DispPlane_0;
        break;

        case    LAY_1:
            //layer 1
            Plane = DispPlane_1;
        break;

        case    LAY_2:
            //layer 2
            Plane = DispPlane_2;
        break;
    }//

    //walk a 1 along the integer, checking each bit
    //if a bit is 'set', turn the corresponding output 'on'
    mask = 0x0001;
    for( i=0; i<NUM_LEDS_PER_PLANE; i++ )
    {
        digitalWrite( pinPlaneLED[i], (Plane & mask) ? LED_ON:LED_OFF );
        mask << 1;
                 
    }//for
    
}//SetPlane


void UpdatePlaneVars( void )
{
    static int
        planeIndex = 0;
    static unsigned long
        timeDelay = 0,
        timePlane = 0;
    unsigned long
        timeNow;

    //time to update the cube pattern?
    timeNow = millis();
    if( ( timeNow - timePlane) < timeDelay )
        return;

    timePlane = timeNow;

    //just grab new values out of the table
    DispPlane_0 = LEDPatterns[planeIndex].Plane_0;
    DispPlane_1 = LEDPatterns[planeIndex].Plane_1;
    DispPlane_2 = LEDPatterns[planeIndex].Plane_2;

    //get ready for the next update
    planeIndex++;
    if( planeIndex == NUM_PATTERNS )
    {
        //if we've reached the end of the table (LEDs off)
        // - reset the index, and
        // - wait a little longer
        planeIndex = 0;
        timeDelay = CUBE_DELAY_LONG;
    }
    else
        //not at the end of the table; short delay
        timeDelay = CUBE_DELAY_SHORT;
        
}//UpdatePlaneVars

void loop() 
{
    //all loop does is update the layers and update the plane variables
    DriveLEDMatrix();
    UpdatePlaneVars();
    
}//loop

Yah this is my first time coding with arduino.

What about the schematic, is it alright?

nsivakumar:
Yah this is my first time coding with arduino.

What about the schematic, is it alright?

I already mentioned the emitter and collector pins needing to be swapped and the base resistors to be dropped some.

You've drawn your LEDs as dots so I don't know if you have the anode and cathode connections right.

You need to connect pins 2-10 to each of the LEDs on all three layers (you're only showing one...)