Introduction: 3x3x3 LED PVC Light Cube

This 3X3X3 ft. LED PVC cube is the ultimate in mood light fun!   An LED (light emitting diode) will burn longer than traditional bulbs so that you can enjoy your giant light for a LONG LONG time. Build it and see!

Step 1: WARNING!!!

THIS PROJECT WILL COST ABOUT $150
Also.... make sure that your dimensions are planned ahead so that you can fit it through your door after you build it!  (Uh... not that it's from personal experience, really).

Step 2: Gather Your Tools

You will need these tool to make the instructable:

hot glue gun
soldering iron
wire strippers
scissors
a drill (manual or press) : press works better
ruler
PVC cutter
a caliper is also very handy

Step 3: Gather Your Materials

Step 4: Fabricate the Custom PVC Parts for the Cube

First,  you need to fabricate the independent custom parts. Remember...."measure twice, cut once" - in other words, double and triple check your work before cutting.

 *To make the T's:  Cut a hole in 8 of the pieces on the side of the piece as picture 2 illustrates.

 * Cut 24 of the 32 pieces in the place indicated in picture 3.  Do NOT cut the pieces through all the way to the 2nd wall.

 * The last pieces to be fabricated are the rest of the four ways (that should be 8). They DO  need to be cut all the way through.

Step 5: Cut the PVC

Depending on the size of the cube that you want to make, the sections of pipe will all be different lengths.

Be aware that you will have to do some math.... ooh. Shocker. 

A caliper can be very helpful for finding all of the correct dimensions. When I  created the cube, my measurements were pretty funky because  PVC fittings vary in length so, in your best inetrest,  I have left my measurements off. 

The important thing is that the total for each side ends up the same so that the pieces fit together to make the cube.

Step 6: Assembly Time

Glue as you go using PVC cement.  Lay the pieces out in the correct order so you glue them correctly into position - like a map.
  1. First make the base and the top levels detailed in diagram #2. DONT FORGET THE INTERSECTIONS IN THE TIC TAC TOE FOR THESE PIECES ARE THE FABRICATED PIECES DRILLED HALF OF THE WAY THROUGH.
  2. Next make the remaining middle layers detailed in diagram #3 DONT FORGET THE INTERSECTIONS IN THE TIC TAC TOE FOR THESE PIECES ARE THE FABRICATED PIECES DRILLED ALL THE WAY THROUGH.
  3. Next you want to make the 4-3ft (in my case) middle PVC bars.  These bars needs to be solid pieces DO NOT CUT THESE PIECES.
  4. Now make the walls of the cube and assemble the PVC fittings on those walls shown in picture #4.
  5.  It is time to put in the middle two layers. To do this step,  take off the top and slide the two remaining levels onto the sliding bars in the center and fit the fabricated and  shaped pieces to the pipe.
At this point, your cube structure should be complete.


Step 7: Stringing the Cube

To hold the LED in the center of the independent cubes I used fishing line to put XES in the cubes as depicted in picture #1.

Step 8: LED Prep

The LEDs need to be soldered to lead wires. Therse wires should be at least 4 inches long and must be stripped at least an inch in each side. 
Double check the connection between the solder and the exposed copper of the lead wire to make sure that the bond is strong.

 The next thing you want to make is a an LED  tester.  You can use a 3 - volt battery or even the Arduino®.  Just make sure that you know which side is the positive and which is the negative.

LED stands for light emitting diode.  In a diode,  electricity only flows in one direction so if you hook up theLED and it doesn't work the first time do not give up.  Just try it the other way.

At this point,  find the diode ( the negative side) of each LED and mark it somehow.  This an important step for the future so....          to save yourself a lot of trouble, double and triple check that negative before you hook it up.

Step 9: LED Placement

Remember the Xes that we made earlier with fishing line?  That is where the LEDs go.

To place the LEDs, wrap both lead wires to their respective sides in the x. Hot glue the wire in place. DON'T HOT GLUE THE STRIPPED PART OF THE WIRE ON BOTH SIDES.

Repeat the process until all LEDs are placed.

Step 10: Wiring

Steps for wiring
  1. Horizantally,  you want to connect the 8 LEDs in each layer,  hooking up all of the negatives in one loop (see picture #1).
  2. Vertically,  on all 8 columns connect all of the positives (see picture #2).
THIS TAKES A WHILE - DON'T GET DISCOURAGED!

Step 11: Additional Custom Wire Making

Here is where you have to be very careful to  follow these steps exactly to properly strip and prepare the cat 5.
  1. The cat 5 cable needs to be 3 feet long.
  2. Take off the main wrapping very, very carefully because the wires are very small.
  3. Strip the 8 independent wires and leave the ground alone.
  4. Do the same thing for the other side of the cable

 Follow these steps exactly to make the other wire:

  1. Cut 3 3 -foot wires of solid core 22 guage wire
  2. Mark both ends of each wire a different color so that you don't confuse them when you plug them into the arduino
  3. Twist these wires together
  4. Hot glue the rest of the wire to keep it in place

Step 12: Wrapping

To wrap the cube all that you have to do is take rice paper and wrap the cube using a weveing patern.

Step 13: Coding

Please rate this instructable if you like it!  here is the code that i used so that you can copy and paste it:

<pre>
k#include&nbsp;&lt;avr/pgmspace.h&gt;&nbsp;<span style="color: #7E7E7E;">// allows use of PROGMEM to store patterns in flash</span>

#define&nbsp;CUBESIZE&nbsp;4
#define&nbsp;PLANESIZE&nbsp;CUBESIZE*CUBESIZE
#define&nbsp;PLANETIME&nbsp;3333&nbsp;<span style="color: #7E7E7E;">// time each plane is displayed in us -&gt; 100 Hz refresh</span>
#define&nbsp;TIMECONST&nbsp;20&nbsp;<span style="color: #7E7E7E;">// multiplies DisplayTime to get ms - why not =100?</span>

<span style="color: #7E7E7E;">//&nbsp;LED&nbsp;Pattern&nbsp;Table&nbsp;in&nbsp;PROGMEM&nbsp;-&nbsp;last&nbsp;column&nbsp;is&nbsp;display&nbsp;time&nbsp;in&nbsp;100ms&nbsp;units</span>
<span style="color: #7E7E7E;">//&nbsp;TODO&nbsp;this&nbsp;could&nbsp;be&nbsp;a&nbsp;lot&nbsp;more&nbsp;compact&nbsp;but&nbsp;not&nbsp;with&nbsp;binary&nbsp;pattern&nbsp;representation</span>
prog_uchar&nbsp;PROGMEM&nbsp;PatternTable[]&nbsp;=&nbsp;{
<span style="color: #7E7E7E;">//&nbsp;blink&nbsp;on&nbsp;and&nbsp;off</span>

B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0011,B0000,B0000,B0000,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0011,B0010,B0000,B0000,B0011,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0011,B0011,B0000,B0000,B0011,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0011,B0011,B0000,B0000,B0011,B0011,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0001,B0011,B0111,B0000,B0001,B0011,B0111,B0000,B0000,B0001,B0011,10,
B0000,B0000,B0000,B0000,B0000,B0011,B0111,B0111,B0000,B0011,B0111,B0111,B0000,B0001,B0011,B0111,10,
B0000,B0000,B0000,B0000,B0000,B0111,B0111,B0111,B0000,B0111,B0111,B0111,B0000,B0011,B0111,B0111,10,
B0000,B0000,B0000,B0000,B0000,B0111,B0111,B0111,B0000,B0111,B0111,B0111,B0000,B0111,B0111,B0111,10,
B0000,B0000,B0000,B0000,B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,10,
B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B0000,B0000,B0000,10,
B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B1100,B1110,B1110,B0000,B0000,B0000,B0000,10,
B0000,B1110,B1110,B1110,B0000,B1100,B1110,B1110,B0000,B1000,B1100,B1110,B0000,B0000,B0000,B0000,10,
B0000,B1100,B1110,B1110,B0000,B1000,B1100,B1110,B0000,B0000,B1000,B1100,B0000,B0000,B0000,B0000,10,
B0000,B1000,B1100,B1110,B0000,B0000,B1000,B1100,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B1000,B1100,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1100,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1110,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1110,B0000,B0000,B0000,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0110,B0000,B0000,B0000,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0010,B0000,B0000,B0000,B0011,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0011,B0001,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0001,B0001,B0001,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1110,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1100,B0000,B0000,B1000,B1000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B0000,B0000,B1100,B1000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1110,B1000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0111,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0011,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0001,B0000,B0001,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0000,B0000,B0011,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0111,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1110,B1000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1100,B1100,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B1110,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0111,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0011,B0000,B0000,10,
B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,10,
B0001,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0011,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0111,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1100,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1110,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B0111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1100,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1110,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0111,B0111,B0111,B0111,B1000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0011,B0011,B0011,B0011,B0100,B0100,B0100,B0100,B1000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,10,
B0001,B0001,B0001,B0001,B0010,B0010,B0010,B0010,B0100,B0100,B0100,B0100,B1000,B1000,B1000,B1000,10,
B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0010,B0010,B0010,B0010,B0100,B0100,B0100,B0100,10,
B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0010,B0010,B0010,B0010,10,
B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,10,
B0010,B0001,B0001,B0001,B0010,B0001,B0001,B0001,B0010,B0001,B0001,B0001,B0010,B0001,B0001,B0001,10,
B0100,B0010,B0001,B0001,B0100,B0010,B0001,B0001,B0100,B0010,B0001,B0001,B0100,B0010,B0001,B0001,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0000,B0010,B0100,B0000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0000,B0000,B0000,B0000,B0000,B0010,B0100,B0000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0010,B0100,B0000,B0001,B0010,B0100,B1000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0010,B0100,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B0000,B0010,B0000,B1000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B0000,B0010,B0000,B1000,B0000,B0010,B1000,B0000,10,
B0000,B0000,B0000,B1000,B0000,B0010,B0000,B1000,B0000,B0010,B1000,B0000,B0000,B0000,B1000,B0000,10,
B0000,B0010,B0000,B1000,B0000,B0010,B1000,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0010,B1000,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0100,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0110,B0110,B0000,B0000,B0100,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1001,B0110,B0110,B1001,B0000,B0110,B0110,B0000,B0000,B0100,B0010,B0000,B0000,B0000,B0000,B0000,10,
B1101,B0111,B1110,B1011,B1001,B0110,B0110,B1001,B0000,B0110,B0110,B0000,B0000,B0100,B0010,B0000,10,
B1111,B1111,B1111,B1111,B1101,B0111,B1110,B1011,B1001,B0110,B0110,B1001,B0000,B0110,B0110,B0000,10,
B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1101,B0111,B1110,B1011,B1001,B0110,B0110,B1001,10,
B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1101,B0111,B1110,B1011,10,
B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,10,
B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,


<span style="color: #7E7E7E;">//&nbsp;this&nbsp;is&nbsp;a&nbsp;dummy&nbsp;element&nbsp;for&nbsp;end&nbsp;of&nbsp;table&nbsp;(duration=0)&nbsp;aka&nbsp;!!!DO&nbsp;NOT&nbsp;TOUCH!!!</span>
B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;B0000,&nbsp;0
};

<span style="color: #7E7E7E;">/*</span>
<span style="color: #7E7E7E;">**&nbsp;Defining&nbsp;pins&nbsp;in&nbsp;array&nbsp;makes&nbsp;it&nbsp;easier&nbsp;to&nbsp;rearrange&nbsp;how&nbsp;cube&nbsp;is&nbsp;wired</span>
<span style="color: #7E7E7E;">**&nbsp;Adjust&nbsp;numbers&nbsp;here&nbsp;until&nbsp;LEDs&nbsp;flash&nbsp;in&nbsp;order&nbsp;-&nbsp;L&nbsp;to&nbsp;R,&nbsp;T&nbsp;to&nbsp;B</span>
<span style="color: #7E7E7E;">**&nbsp;Note&nbsp;that&nbsp;analog&nbsp;inputs&nbsp;0-5&nbsp;are&nbsp;also&nbsp;digital&nbsp;outputs&nbsp;14-19!</span>
<span style="color: #7E7E7E;">**&nbsp;Pin&nbsp;DigitalOut0&nbsp;(serial&nbsp;RX)&nbsp;and&nbsp;AnalogIn5&nbsp;are&nbsp;left&nbsp;open&nbsp;for&nbsp;future&nbsp;apps</span>
<span style="color: #7E7E7E;">*/</span>

<span style="color: #CC6600;">int</span> LEDPin[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
<span style="color: #CC6600;">int</span> PlanePin[] = {16, 17, 18, 19};

<span style="color: #7E7E7E;">//&nbsp;initialization</span>
<span style="color: #CC6600;">void</span> <span style="color: #CC6600;"><b>setup</b></span>()
{
<span style="color: #CC6600;">int</span> pin; <span style="color: #7E7E7E;">// loop counter</span>
<span style="color: #7E7E7E;">//&nbsp;set&nbsp;up&nbsp;LED&nbsp;pins&nbsp;as&nbsp;output&nbsp;(active&nbsp;HIGH)</span>
<span style="color: #CC6600;">for</span> (pin=0; pin&lt;PLANESIZE; pin++) {
<span style="color: #CC6600;">pinMode</span>( LEDPin[pin], <span style="color: #006699;">OUTPUT</span> );
}
<span style="color: #7E7E7E;">//&nbsp;set&nbsp;up&nbsp;plane&nbsp;pins&nbsp;as&nbsp;outputs&nbsp;(active&nbsp;LOW)</span>
<span style="color: #CC6600;">for</span> (pin=0; pin&lt;CUBESIZE; pin++) {
<span style="color: #CC6600;">pinMode</span>( PlanePin[pin], <span style="color: #006699;">OUTPUT</span> );
}
}

<span style="color: #7E7E7E;">//&nbsp;display&nbsp;pattern&nbsp;in&nbsp;table&nbsp;until&nbsp;DisplayTime&nbsp;is&nbsp;zero&nbsp;(then&nbsp;repeat)</span>
<span style="color: #CC6600;">void</span> <span style="color: #CC6600;"><b>loop</b></span>()
{
<span style="color: #7E7E7E;">//&nbsp;declare&nbsp;variables</span>
<span style="color: #CC6600;">byte</span> PatternBuf[PLANESIZE]; <span style="color: #7E7E7E;">// saves current pattern from PatternTable</span>
<span style="color: #CC6600;">int</span> PatternIdx;
<span style="color: #CC6600;">byte</span> DisplayTime; <span style="color: #7E7E7E;">// time*100ms to display pattern</span>
<span style="color: #CC6600;">unsigned</span> <span style="color: #CC6600;">long</span> EndTime;
<span style="color: #CC6600;">int</span> plane; <span style="color: #7E7E7E;">// loop counter for cube refresh</span>
<span style="color: #CC6600;">int</span> patbufidx; <span style="color: #7E7E7E;">// indexes which byte from pattern buffer</span>
<span style="color: #CC6600;">int</span> ledrow; <span style="color: #7E7E7E;">// counts LEDs in refresh loop</span>
<span style="color: #CC6600;">int</span> ledcol; <span style="color: #7E7E7E;">// counts LEDs in refresh loop</span>
<span style="color: #CC6600;">int</span> ledpin; <span style="color: #7E7E7E;">// counts LEDs in refresh loop</span>

<span style="color: #7E7E7E;">//&nbsp;Initialize&nbsp;PatternIdx&nbsp;to&nbsp;beginning&nbsp;of&nbsp;pattern&nbsp;table</span>
PatternIdx&nbsp;=&nbsp;0;
<span style="color: #7E7E7E;">//&nbsp;loop&nbsp;over&nbsp;entries&nbsp;in&nbsp;pattern&nbsp;table&nbsp;-&nbsp;while&nbsp;DisplayTime&gt;0</span>
<span style="color: #CC6600;">do</span> {
<span style="color: #7E7E7E;">//&nbsp;read&nbsp;pattern&nbsp;from&nbsp;PROGMEM&nbsp;and&nbsp;save&nbsp;in&nbsp;array</span>
memcpy_P(&nbsp;PatternBuf,&nbsp;PatternTable+PatternIdx,&nbsp;PLANESIZE&nbsp;);
PatternIdx&nbsp;+=&nbsp;PLANESIZE;
<span style="color: #7E7E7E;">//&nbsp;read&nbsp;DisplayTime&nbsp;from&nbsp;PROGMEM&nbsp;and&nbsp;increment&nbsp;index</span>
DisplayTime&nbsp;=&nbsp;pgm_read_byte_near(&nbsp;PatternTable&nbsp;+&nbsp;PatternIdx++&nbsp;);
<span style="color: #7E7E7E;">//&nbsp;compute&nbsp;EndTime&nbsp;from&nbsp;current&nbsp;time&nbsp;(ms)&nbsp;and&nbsp;DisplayTime</span>
EndTime&nbsp;=&nbsp;<span style="color: #CC6600;">millis</span>() + ((<span style="color: #CC6600;">unsigned</span> <span style="color: #CC6600;">long</span>) DisplayTime) * TIMECONST;

<span style="color: #7E7E7E;">//&nbsp;loop&nbsp;while&nbsp;DisplayTime&gt;0&nbsp;and&nbsp;current&nbsp;time&nbsp;&lt;&nbsp;EndTime</span>
<span style="color: #CC6600;">while</span> ( <span style="color: #CC6600;">millis</span>() &lt; EndTime ) {
patbufidx&nbsp;=&nbsp;0;&nbsp;<span style="color: #7E7E7E;">// reset index counter to beginning of buffer</span>
<span style="color: #7E7E7E;">//&nbsp;loop&nbsp;over&nbsp;planes</span>
<span style="color: #CC6600;">for</span> (plane=0; plane&lt;CUBESIZE; plane++) {
<span style="color: #7E7E7E;">//&nbsp;turn&nbsp;previous&nbsp;plane&nbsp;off</span>
<span style="color: #CC6600;">if</span> (plane==0) {
<span style="color: #CC6600;">digitalWrite</span>( PlanePin[CUBESIZE-1], <span style="color: #006699;">HIGH</span> );
}&nbsp;<span style="color: #CC6600;">else</span> {
<span style="color: #CC6600;">digitalWrite</span>( PlanePin[plane-1], <span style="color: #006699;">HIGH</span> );
}

<span style="color: #7E7E7E;">//&nbsp;load&nbsp;current&nbsp;plane&nbsp;pattern&nbsp;data&nbsp;into&nbsp;ports</span>
ledpin&nbsp;=&nbsp;0;
<span style="color: #CC6600;">for</span> (ledrow=0; ledrow&lt;CUBESIZE; ledrow++) {
<span style="color: #CC6600;">for</span> (ledcol=0; ledcol&lt;CUBESIZE; ledcol++) {
<span style="color: #CC6600;">digitalWrite</span>( LEDPin[ledpin++], PatternBuf[patbufidx] &amp; (1 &lt;&lt; ledcol) );
}
patbufidx++;
}

<span style="color: #7E7E7E;">//&nbsp;turn&nbsp;current&nbsp;plane&nbsp;on</span>
<span style="color: #CC6600;">digitalWrite</span>( PlanePin[plane], <span style="color: #006699;">LOW</span> );
<span style="color: #7E7E7E;">//&nbsp;delay&nbsp;PLANETIME&nbsp;us</span>
<span style="color: #CC6600;">delayMicroseconds</span>( PLANETIME );
}&nbsp;<span style="color: #7E7E7E;">// for plane</span>
}&nbsp;<span style="color: #7E7E7E;">// while &lt;EndTime</span>
}&nbsp;<span style="color: #CC6600;">while</span> (DisplayTime &gt; 0); <span style="color: #7E7E7E;">// read patterns until time=0 which signals end</span>
}

</pre>

Arduino Challenge

Participated in the
Arduino Challenge