4x4x4 LED Cube (Arduino Uno)

574,641

1,091

168

Introduction: 4x4x4 LED Cube (Arduino Uno)

In this tutorial I'll show you how to make a 4x4x4 LED cube for around $15.00. The cube has 64 green LEDs which make up it's 4 layers(positives) and 16 columns(negatives). These are all wired to a Arduino Uno. An Arduino is a single-board microcontroller, intended to make the application of interactive objects or environments more accessible. The hardware consists of an open-source hardware board designed around an 8-bit Atmel AVR microcontroller, or a 32-bit Atmel ARM. I programed code(sketches) for the Arduino Uno to controll the individual LEDs to display patterns for this captivating desktop light show.

Watch The Video:

-----------------------------------------------------------------------------------------------------

Besides the fun of making and posting this instructable, this project is an entry for the Tech, Teach It, and Epilog Challenge VI Contests. I would really appreciate your vote!

Please click on the orange vote ribbon in the upper right-hand corner of this

page if you enjoy this Instructable.

-----------------------------------------------------------------------------------------------------

Step 1: What You Will Need:

Parts/ Materials:

  1. 64 Diffused LEDs $2.00
  2. 4 100 OHM Resistors $1.00
  3. Pin Header $0.50
  4. Slide Switch $1.00
  5. Wire $0.75
  6. Craft Wire $0.25
  7. Perf Board $2.00
  8. Project Box $6.00
  9. 9V Power Supply $1.00

Total Cost: $14.50

Tools/ Adhesives:

  • Arduino Uno
  • Drill
  • 1/16" Drill Bit
  • 5/16" Drill Bit
  • Knife
  • Straight Edge
  • Needle Nose Pliers
  • Soldering Iron
  • Solder
  • Hot Glue Gun

Step 2: Making the LED Jig

First, Start by printing out my 4x4x4 LED Cube Template and paste it to a cardboard box.Make sure that the printing settings are set to actual size and landscape orientation. Next, punch out all 16 LED holes(grey dashed circles) using a pencil. Insert a LED into the individual holes to test the fit.

Step 3: Making the LED Cube

Take the 64 LEDs and test them to ensure that they all work using a button cell battery. This may sound tedious but in the end this will safe-guard your your project! Next, insert 16 LEDs into the holes and bend the leads to the direction of the arrows using needle nose pliers. The red arrows represent the positives(anodes) likewise the blue arrows represent the negatives(cathodes). Solder all of the positive leads together and trim off the access of the leads. Now, you might have noticed that there are two gaps in the layer of the positive leads. This can be solved by straightening a length of craft wire by pulling both ends of the wire with pliers and trimming two 1" sections that are then soldered in place. After the hole positive layer is soldered together, flip the box over and start pushing the tips of the LEDs out of the holes in the jig. Make sure to do this evenly to avoid bending or damaging the layers structure. Now your first LED layer is finished! Follow this step three more times to end up with four layers. Next, take the four LED layers and solder the negative leads together by stacking the individual layers on the top of each other. Start by soldering the leads in the center, then work out to the leads on the edge. The 4x4x4 LED cube is starting to take shape! Straghten another length of craft wire and cut and bend four sections that will later connect the four layers to the perf board. Finally, solder them in place.

Step 4: Installing the LED Cube

Start by marking an outline of a square with a Sharpie that is slightly smaller than the interior sides of project box on the perf board. Use a straight edge and a knife to score the outline along the lines, then break off the access material by placing the perf board in a vise or on the edge of a table, then apply pressure till the scored sides snap off. Next, drill 20 holes with a 1/16" drill bit for the leads on the top of the project box. An easy way of doing this is by marking the holes where the leads poke out of the perf board and then taping the board to the top of the project box. Next mark the 20 holes on the top of the box through the board with a sharpened pencil. Take the perf board off and drill where the markings are on the project box. Then glue the perf board inside of the box with some hot glue. Make sure that all 20 holes line up with the holes on the perf board. Next install the LED cube by carefully inserting each lead through the holes on the project box. Finally, solder the leads in place, then trim off the access wire.

Step 5: Wiring the Circuit

First, snap the pin header in to 3 pieces that fit the Arduino Unos digital and analog plug-ins. Strip and start soldering wires to the 16 digital leads(columns) on the perf board. For the 4 analog leads(layers), solder 100 OHM resisters to the leads then solder wires to each resisters lead. Next strip and solder the opposite ends of the wires to the 3 pin headers. The wiring is setup to resemble a graph with a 3rd dimension. For the columns, there are two axes X and Y. In addition, the layers serve as the Z axis. If you look straight down from the top of the LED cube it looks like the 1st quadrant on a graph except that the origin is (1,1) on the cube. Likewise each LED can be named using the fundamental graphing technique. Lets try an example; look at the demonstrational picture and find A(1,4). "A" means that it is on the first layer and "(1,4)" is X=1,Y=4 on the graph.

Connection Setup:

Columns

[(x,y)-Pin]

  • (1,1)-13
  • (1,2)-12
  • (1,3)-11
  • (1,4)-10
  • (2,1)-9
  • (2,2)-8
  • (2,3)-7
  • (2,4)-6
  • (3,1)-5
  • (3-2)-4
  • (3-3)-3
  • (3,4)-2
  • (4,1)-1
  • (4,2)-0
  • (4,3)-A5
  • (4,4)-A4

Layers

[Layer-Pin]

  • a-A0
  • b-A1
  • c-A2
  • d-A3

    Step 6: Installing the Arduino/ Power Supply

    Take the sliding switch and cut the mounting tabs off with the wire snips on the needle nose pliers. Next, cut and strip the positive wires of the power supply and solder the switch to the positive leads. Drill a hole on the side of the project box with a 5/16" drill bit. Make sure to work up to the 5/16" hole in increments of bit sizes. Carve away the plastic ribs in the interior of the box near the hole with a knife, then hot glue the switch in place. Next, plug the pin headers and the 9v power supply into the Arduino Uno. Lastly, upload the code(sketch) to the Arduino then tighten the bottom lid on to project box. Now the 4x4x4 LED cube is finally finished!

    Enjoy!

    Want more instructables?Please favorite, follow, and comment for more creative builds, hacks, and more.

    Thanks, KyleTheCreator

    The Code!

    I found this sketch online, then I edited it to work for my LED cube. Soon, I'll have my own sketch that will be posted right here, on this i'ble. But for now, if you have any improvements or add-ons to this current sketch, let me know so I can keep it updated:)

    Step 7: I Made It! Gallery

    This is a gallery of the 4x4x4 LED cubes that members of the community have made by following this instructable. If you would like to have your LED cube featured, click the "I Made It!" button to post it in the comments and I will add it right here, in the "I Made It!" gallery.

    Teach It! Contest Sponsored by Dremel

    Participated in the
    Teach It! Contest Sponsored by Dremel

    Tech Contest

    Participated in the
    Tech Contest

    Epilog Challenge VI

    Participated in the
    Epilog Challenge VI

    80 People Made This Project!

    Recommendations

    • Make It Bridge

      Make It Bridge
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Big and Small Contest

      Big and Small Contest

    168 Comments

    0
    Grisling
    Grisling

    8 years ago

    great instructable...I will make this when my order of LED's come in :)

    0
    KyleTheCreator
    KyleTheCreator

    Reply 8 years ago on Introduction

    Thanks for your feedback Grisling! When you make your LED cube, don't forget to click the "I made it!" button and post a picture of it here, in the comments. I would really enjoy seeing it:D

    0
    JonathanS188
    JonathanS188

    6 years ago

    If I wanted to buy 3mm led uV at 3volt could this work, would I have to change resisters. I am only just getting in to electronics after buying a uno v3 and want to make this box with UV. I am only asking because yours for this tutorial are 2volts. If you could help me to know that LEDs will be fine to buy for this project :-)

    http://m.ebay.com/itm/100-x-LED-3mm-UV-Purple-Diffused-Ultra-Bright-Round-Top-LEDs-Light-Lamp-RC-Car-/161364818280?nav=SEARCH

    0
    stevetob67
    stevetob67

    Reply 1 year ago

    yes, just go to a LED Resistor Calculator site (Google Search) and calculate the required resistor

    0
    CraigA52
    CraigA52

    6 years ago

    Is it possible to build this cube using an arduino nano?

    0
    stevetob67
    stevetob67

    Reply 1 year ago

    I am about to try, I have checked the ports and the nano has enough

    0
    MattS315
    MattS315

    6 years ago

    Could you please post a new link to a recommeded slide switch?

    0
    stevetob67
    stevetob67

    Reply 1 year ago

    any switch will work, even a push button or a flick switch

    0
    meistarlemon
    meistarlemon

    6 years ago

    Hey when you're stacking the layers on top of each other, do the parallel lines inside the square go on top of each other or across each other?

    0
    stevetob67
    stevetob67

    Reply 1 year ago

    the negative (cathode) pin of each layer joins with the negative (cathode) pin on the previous layer and the bottom is soldered onto the perf board then the I/O of the Arduino board. The Anode (positive) goes to the power output of the Arduino board

    0
    HamzaF5
    HamzaF5

    6 years ago

    i need just code free

    0
    stevetob67
    stevetob67

    Reply 1 year ago

    it is supplied free, just click the download button for the code.
    I will paste it here

    /*
    4x4x4 LED Cube
    Connection Setup:
    Columns
    [(x,y)-Pin]
    (1,1)-13
    (1,2)-12
    (1,3)-11
    (1,4)-10
    (2,1)-9
    (2,2)-8
    (2,3)-7
    (2,4)-6
    (3,1)-5
    (3-2)-4
    (3-3)-3
    (3,4)-2
    (4,1)-1
    (4,2)-0
    (4,3)-A5
    (4,4)-A4
    Layers
    [layer-Pin]
    a-A0
    b-A1
    c-A2
    d-A3
    */
    //initializing and declaring led rows
    int column[16]={13,12,11,10,9,8,7,6,5,4,3,2,1,0,A5,A4};
    //initializing and declaring led layers
    int layer[4]={A3,A2,A1,A0};

    int time = 250;
    void setup()
    {
    //setting rows to ouput
    for(int i = 0; i<16; i++)
    {
    pinMode(column[i], OUTPUT);
    }
    //setting layers to output
    for(int i = 0; i<4; i++)
    {
    pinMode(layer[i], OUTPUT);
    }
    //seeding random for random pattern
    randomSeed(analogRead(10));
    }
    //xxxxxxxxxxxxxxxxxxxxFUNCTION LOOPxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    void loop()
    {
    turnEverythingOff();//turn all off
    flickerOn();
    turnEverythingOn();//turn all on
    delay(time);
    turnOnAndOffAllByLayerUpAndDownNotTimed();
    layerstompUpAndDown();
    turnOnAndOffAllByColumnSideways();
    delay(time);
    aroundEdgeDown();
    turnEverythingOff();
    randomflicker();
    randomRain();
    diagonalRectangle();
    goThroughAllLedsOneAtATime();
    propeller();
    spiralInAndOut();
    flickerOff();
    turnEverythingOff();
    delay(2000);
    }


    //xxxxxxxxxxxxxxxxxxxxFUNCTIONSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    ///////////////////////////////////////////////////////////turn all off
    void turnEverythingOff()
    {
    for(int i = 0; i<16; i++)
    {
    digitalWrite(column[i], 1);
    }
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 0);
    }
    }
    ////////////////////////////////////////////////////////////turn all on
    void turnEverythingOn()
    {
    for(int i = 0; i<16; i++)
    {
    digitalWrite(column[i], 0);
    }
    //turning on layers
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 1);
    }
    }
    ///////////////////////////////////////////////////////turn columns off
    void turnColumnsOff()
    {
    for(int i = 0; i<16; i++)
    {
    digitalWrite(column[i], 1);
    }
    }
    /////////////////////////////////////////////////////////////flicker on
    void flickerOn()
    {
    int i = 150;
    while(i != 0)
    {
    turnEverythingOn();
    delay(i);
    turnEverythingOff();
    delay(i);
    i-= 5;
    }
    }
    //////////////turn everything on and off by layer up and down NOT TIMED
    void turnOnAndOffAllByLayerUpAndDownNotTimed()
    {
    int x = 75;
    for(int i = 5; i != 0; i--)
    {
    turnEverythingOn();
    for(int i = 4; i!=0; i--)
    {
    digitalWrite(layer[i-1], 0);
    delay(x);
    }
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 1);
    delay(x);
    }
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 0);
    delay(x);
    }
    for(int i = 4; i!=0; i--)
    {
    digitalWrite(layer[i-1], 1);
    delay(x);
    }
    }
    }
    //////////////////////////turn everything on and off by column sideways
    void turnOnAndOffAllByColumnSideways()
    {
    int x = 75;
    turnEverythingOff();
    //turn on layers
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 1);
    }
    for(int y = 0; y<3; y++)
    {
    //turn on 0-3
    for(int i = 0; i<4; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn on 4-7
    for(int i = 4; i<8; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn on 8-11
    for(int i = 8; i<12; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn on 12-15
    for(int i = 12; i<16; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn off 0-3
    for(int i = 0; i<4; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    //turn off 4-7
    for(int i = 4; i<8; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    //turn off 8-11
    for(int i = 8; i<12; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    //turn off 12-15
    for(int i = 12; i<16; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    //turn on 12-15
    for(int i = 12; i<16; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn on 8-11
    for(int i = 8; i<12; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn on 4-7
    for(int i = 4; i<8; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn on 0-3
    for(int i = 0; i<4; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    }
    //turn off 12-15
    for(int i = 12; i<16; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    //turn off 8-11
    for(int i = 8; i<12; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    //turn off 4-7
    for(int i = 4; i<8; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    //turn off 0-3
    for(int i = 0; i<4; i++)
    {
    digitalWrite(column[i], 1);
    delay(x);
    }
    }
    }
    /////////////////////////////////////////up and down single layer stomp
    void layerstompUpAndDown()
    {
    int x = 75;
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 0);
    }
    for(int y = 0; y<5; y++)
    {
    for(int count = 0; count<1; count++)
    {
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 1);
    delay(x);
    digitalWrite(layer[i], 0);
    }
    for(int i = 4; i !=0; i--)
    {
    digitalWrite(layer[i-1], 1);
    delay(x);
    digitalWrite(layer[i-1], 0);
    }
    }
    for(int i = 0; i<4; i++)
    {
    digitalWrite(layer[i], 1);
    delay(x);
    }
    for(int i = 4; i!=0; i--)
    {
    digitalWrite(layer[i-1], 0);
    delay(x);
    }
    }
    }
    ////////////////////////////////////////////////////////////flicker off
    void flickerOff()
    {
    turnEverythingOn();
    for(int i = 0; i!= 150; i+=5)
    {
    turnEverythingOff();
    delay(i+50);
    turnEverythingOn();
    delay(i);
    }
    }
    ///////////////////////////////////////////around edge of the cube down
    void aroundEdgeDown()
    {
    for(int x = 200; x != 0; x -=50)
    {
    turnEverythingOff();
    for(int i = 4; i != 0; i--)
    {
    digitalWrite(layer[i-1], 1);
    digitalWrite(column[5], 0);
    digitalWrite(column[6], 0);
    digitalWrite(column[9], 0);
    digitalWrite(column[10], 0);
    digitalWrite(column[0], 0);
    delay(x);
    digitalWrite(column[0], 1);
    digitalWrite(column[4], 0);
    delay(x);
    digitalWrite(column[4], 1);
    digitalWrite(column[8], 0);
    delay(x);
    digitalWrite(column[8], 1);
    digitalWrite(column[12], 0);
    delay(x);
    digitalWrite(column[12], 1);
    digitalWrite(column[13], 0);
    delay(x);
    digitalWrite(column[13], 1);
    digitalWrite(column[15], 0);
    delay(x);
    digitalWrite(column[15], 1);
    digitalWrite(column[14], 0);
    delay(x);
    digitalWrite(column[14], 1);
    digitalWrite(column[11], 0);
    delay(x);
    digitalWrite(column[11], 1);
    digitalWrite(column[7], 0);
    delay(x);
    digitalWrite(column[7], 1);
    digitalWrite(column[3], 0);
    delay(x);
    digitalWrite(column[3], 1);
    digitalWrite(column[2], 0);
    delay(x);
    digitalWrite(column[2], 1);
    digitalWrite(column[1], 0);
    delay(x);
    digitalWrite(column[1], 1);
    }
    }
    }
    /////////////////////////////////////////////////////////random flicker
    void randomflicker()
    {
    turnEverythingOff();
    int x = 10;
    for(int i = 0; i !=750; i+=2)
    {
    int randomLayer = random(0,4);
    int randomColumn = random(0,16);
    digitalWrite(layer[randomLayer], 1);
    digitalWrite(column[randomColumn], 0);
    delay(x);
    digitalWrite(layer[randomLayer], 0);
    digitalWrite(column[randomColumn], 1);
    delay(x);
    }
    }
    ////////////////////////////////////////////////////////////random rain
    void randomRain()
    {
    turnEverythingOff();
    int x = 100;
    for(int i = 0; i!=60; i+=2)
    {
    int randomColumn = random(0,16);
    digitalWrite(column[randomColumn], 0);
    digitalWrite(layer[0], 1);
    delay(x+50);
    digitalWrite(layer[0], 0);
    digitalWrite(layer[1], 1);
    delay(x);
    digitalWrite(layer[1], 0);
    digitalWrite(layer[2], 1);
    delay(x);
    digitalWrite(layer[2], 0);
    digitalWrite(layer[3], 1);
    delay(x+50);
    digitalWrite(layer[3], 0);
    digitalWrite(column[randomColumn], 1);
    }
    }
    /////////////////////////////////////////////////////diagonal rectangle
    void diagonalRectangle()
    {
    int x = 350;
    turnEverythingOff();
    for(int count = 0; count<5; count++)
    {
    //top left
    for(int i = 0; i<8; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[3], 1);
    digitalWrite(layer[2], 1);
    delay(x);
    turnEverythingOff();
    //middle middle
    for(int i = 4; i<12; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[1], 1);
    digitalWrite(layer[2], 1);
    delay(x);
    turnEverythingOff();
    //bottom right
    for(int i = 8; i<16; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[0], 1);
    digitalWrite(layer[1], 1);
    delay(x);
    turnEverythingOff();
    //bottom middle
    for(int i = 4; i<12; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[0], 1);
    digitalWrite(layer[1], 1);
    delay(x);
    turnEverythingOff();
    //bottom left
    for(int i = 0; i<8; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[0], 1);
    digitalWrite(layer[1], 1);
    delay(x);
    turnEverythingOff();
    //middle middle
    for(int i = 4; i<12; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[1], 1);
    digitalWrite(layer[2], 1);
    delay(x);
    turnEverythingOff();
    //top right
    for(int i = 8; i<16; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[2], 1);
    digitalWrite(layer[3], 1);
    delay(x);
    turnEverythingOff();
    //top middle
    for(int i = 4; i<12; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[2], 1);
    digitalWrite(layer[3], 1);
    delay(x);
    turnEverythingOff();
    }
    //top left
    for(int i = 0; i<8; i++)
    {
    digitalWrite(column[i], 0);
    }
    digitalWrite(layer[3], 1);
    digitalWrite(layer[2], 1);
    delay(x);
    turnEverythingOff();
    }
    //////////////////////////////////////////////////////////////propeller
    void propeller()
    {
    turnEverythingOff();
    int x = 90;
    for(int y = 4; y>0; y--)
    {
    for(int i = 0; i<6; i++)
    {
    //turn on layer
    digitalWrite(layer[y-1], 1);
    //a1
    turnColumnsOff();
    digitalWrite(column[0], 0);
    digitalWrite(column[5], 0);
    digitalWrite(column[10], 0);
    digitalWrite(column[15], 0);
    delay(x);
    //b1
    turnColumnsOff();
    digitalWrite(column[4], 0);
    digitalWrite(column[5], 0);
    digitalWrite(column[10], 0);
    digitalWrite(column[11], 0);
    delay(x);
    //c1
    turnColumnsOff();
    digitalWrite(column[6], 0);
    digitalWrite(column[7], 0);
    digitalWrite(column[8], 0);
    digitalWrite(column[9], 0);
    delay(x);
    //d1
    turnColumnsOff();
    digitalWrite(column[3], 0);
    digitalWrite(column[6], 0);
    digitalWrite(column[9], 0);
    digitalWrite(column[12], 0);
    delay(x);
    //d2
    turnColumnsOff();
    digitalWrite(column[2], 0);
    digitalWrite(column[6], 0);
    digitalWrite(column[9], 0);
    digitalWrite(column[13], 0);
    delay(x);
    //d3
    turnColumnsOff();
    digitalWrite(column[1], 0);
    digitalWrite(column[5], 0);
    digitalWrite(column[10], 0);
    digitalWrite(column[14], 0);
    delay(x);
    }
    }
    //d4
    turnColumnsOff();
    digitalWrite(column[0], 0);
    digitalWrite(column[5], 0);
    digitalWrite(column[10], 0);
    digitalWrite(column[15], 0);
    delay(x);
    }
    //////////////////////////////////////////////////////spiral in and out
    void spiralInAndOut()
    {
    turnEverythingOn();
    int x = 60;
    for(int i = 0; i<6; i++)
    {
    //spiral in clockwise
    digitalWrite(column[0], 1);
    delay(x);
    digitalWrite(column[1], 1);
    delay(x);
    digitalWrite(column[2], 1);
    delay(x);
    digitalWrite(column[3], 1);
    delay(x);
    digitalWrite(column[7], 1);
    delay(x);
    digitalWrite(column[11], 1);
    delay(x);
    digitalWrite(column[15], 1);
    delay(x);
    digitalWrite(column[14], 1);
    delay(x);
    digitalWrite(column[13], 1);
    delay(x);
    digitalWrite(column[12], 1);
    delay(x);
    digitalWrite(column[8], 1);
    delay(x);
    digitalWrite(column[4], 1);
    delay(x);
    digitalWrite(column[5], 1);
    delay(x);
    digitalWrite(column[6], 1);
    delay(x);
    digitalWrite(column[10], 1);
    delay(x);
    digitalWrite(column[9], 1);
    delay(x);
    ///////////////////////////////////////spiral out counter clockwise
    digitalWrite(column[9], 0);
    delay(x);
    digitalWrite(column[10], 0);
    delay(x);
    digitalWrite(column[6], 0);
    delay(x);
    digitalWrite(column[5], 0);
    delay(x);
    digitalWrite(column[4], 0);
    delay(x);
    digitalWrite(column[8], 0);
    delay(x);
    digitalWrite(column[12], 0);
    delay(x);
    digitalWrite(column[13], 0);
    delay(x);
    digitalWrite(column[14], 0);
    delay(x);
    digitalWrite(column[15], 0);
    delay(x);
    digitalWrite(column[11], 0);
    delay(x);
    digitalWrite(column[7], 0);
    delay(x);
    digitalWrite(column[3], 0);
    delay(x);
    digitalWrite(column[2], 0);
    delay(x);
    digitalWrite(column[1], 0);
    delay(x);
    digitalWrite(column[0], 0);
    delay(x);
    ///////////////////////////////////////spiral in counter clock wise
    digitalWrite(column[0], 1);
    delay(x);
    digitalWrite(column[4], 1);
    delay(x);
    digitalWrite(column[8], 1);
    delay(x);
    digitalWrite(column[12], 1);
    delay(x);
    digitalWrite(column[13], 1);
    delay(x);
    digitalWrite(column[14], 1);
    delay(x);
    digitalWrite(column[15], 1);
    delay(x);
    digitalWrite(column[11], 1);
    delay(x);
    digitalWrite(column[7], 1);
    delay(x);
    digitalWrite(column[3], 1);
    delay(x);
    digitalWrite(column[2], 1);
    delay(x);
    digitalWrite(column[1], 1);
    delay(x);
    digitalWrite(column[5], 1);
    delay(x);
    digitalWrite(column[9], 1);
    delay(x);
    digitalWrite(column[10], 1);
    delay(x);
    digitalWrite(column[6], 1);
    delay(x);
    //////////////////////////////////////////////spiral out clock wise
    digitalWrite(column[6], 0);
    delay(x);
    digitalWrite(column[10], 0);
    delay(x);
    digitalWrite(column[9], 0);
    delay(x);
    digitalWrite(column[5], 0);
    delay(x);
    digitalWrite(column[1], 0);
    delay(x);
    digitalWrite(column[2], 0);
    delay(x);
    digitalWrite(column[3], 0);
    delay(x);
    digitalWrite(column[7], 0);
    delay(x);
    digitalWrite(column[11], 0);
    delay(x);
    digitalWrite(column[15], 0);
    delay(x);
    digitalWrite(column[14], 0);
    delay(x);
    digitalWrite(column[13], 0);
    delay(x);
    digitalWrite(column[12], 0);
    delay(x);
    digitalWrite(column[8], 0);
    delay(x);
    digitalWrite(column[4], 0);
    delay(x);
    digitalWrite(column[0], 0);
    delay(x);
    }
    }
    //////////////////////////////////////go through all leds one at a time
    void goThroughAllLedsOneAtATime()
    {
    int x = 15;
    turnEverythingOff();
    for(int y = 0; y<5; y++)
    {
    //0-3
    for(int count = 4; count != 0; count--)
    {
    digitalWrite(layer[count-1], 1);
    for(int i = 0; i<4; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    digitalWrite(column[i], 1);
    delay(x);
    }
    digitalWrite(layer[count-1], 0);
    }
    //4-7
    for(int count = 0; count < 4; count++)
    {
    digitalWrite(layer[count], 1);
    for(int i = 4; i<8; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    digitalWrite(column[i], 1);
    delay(x);
    }
    digitalWrite(layer[count], 0);
    }
    //8-11
    for(int count = 4; count != 0; count--)
    {
    digitalWrite(layer[count-1], 1);
    for(int i = 8; i<12; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    digitalWrite(column[i], 1);
    delay(x);
    }
    digitalWrite(layer[count-1], 0);
    }
    //12-15
    for(int count = 0; count < 4; count++)
    {
    digitalWrite(layer[count], 1);
    for(int i = 12; i<16; i++)
    {
    digitalWrite(column[i], 0);
    delay(x);
    digitalWrite(column[i], 1);
    delay(x);
    }
    digitalWrite(layer[count], 0);
    }
    }
    }
    0
    avery2103
    avery2103

    5 years ago

    Can you alter the code to create different light patterns

    0
    stevetob67
    stevetob67

    Reply 1 year ago

    yes, if you look around on the internet you will see other projects that perform different patterns. You could use parts of the code in those projects to edit the supplied project, just make sure to back up the origional first or give the altered project a new name before you save and possibly overwrite the supplied project. (or download it again if you stuff up)

    0
    martin.pfitzner.942
    martin.pfitzner.942

    5 years ago

    How have you built this without NPN transistors to switch on and off the layers?
    I tested your code with my previously built cube (including 4 NPNs) and it works.

    0
    stevetob67
    stevetob67

    Reply 1 year ago

    the code switches the port on and off much the same way that the gate of a trasistor acts as a switch to turn the current flow on and off

    0
    Krypto_
    Krypto_

    Question 1 year ago on Introduction

    How many Watt ohm resistor I have to use?? I see 1 watt, 1/2 watt, 1/4 watt 100 ohm resistor on Amazon.....which should I order?

    0
    stevetob67
    stevetob67

    Answer 1 year ago

    1/4 watt will be enough because the Arduino only outputs about 40ma per port

    0
    stevetob67
    stevetob67

    Question 1 year ago

    Would this work on the Arduino Nano, from what I can see there should be enough ports

    0
    jaymez161391282
    jaymez161391282

    Tip 1 year ago

    I wired it different than i have seen anyone else although a few people came close to what i was going for but most had wires going everywhere and crossing each other let me know if you would do something different. I need help with the negative wires they don't have the same flow and simplicity as the positives. And i want to make it easy to look at and understand the circuit my son is 6 and i feel if the wires are crossing and looks messy he won't even try to understand each led is separately connected.

    20210204_065402.jpg20210204_065421.jpg20210204_065334.jpg