Hi All.
I have looked around and see a lot of information out there about RGB LRD cubes, some good some not so good, IMHO.
Thought I would put up a thread about my cube and things I know now, after make a cube and running my cube for a few years. My Cube is 8 x 8 x12high, using 5mm RGB LEDs. Very much following the concept designed by Kevin Darrah (on http://www.kevindarrah.com)
Check out my cube here RGB LED Cube "Rectangular Prism" Bragging Rights | All modding! | Pinside.com
First thing. Everyone talks about a cube that is 8 LEDs wide, 8 LEDs deep and 8 LEDs high (8 x 8 x 8 = 512 LEDs). WHY? Well I guess that 8 fits AVR architecture nicely.
The issue with this arrangement is there is no center, so consider making a cube with odd numbers EG 9 x 9 x 9. Having a center will make your animations work better in many cases. My next cube will contain an odd number of LEDs. As for programming, If you write to your LED array a bit like the code below, having any number of LEDs will work. Yes you will require more memory for more LEDs.
Height, I found having a bit more room in the height good for animations. I have room for a ball to bounce. More room for the rain to fall. My cube is 150% higher than its width. Adding height does not make programming any harder.
//*********** Defining the Cube *************
#define BAM_RESOLUTION 4 // EG 4 bit colour = 15 variation of R, G & B (4096 colours)
const byte Size_Y = 12;//Number of Layers Y axis (levels/Layers)
const byte Size_X = 8; //Number of LEDs X axis (Left to right across front)
const byte Size_Z = 8; //Number of LEDs Z axis (front to back)
const int Size_Layer = Size_X * Size_Z; // Number of LEDs per Layer
const int Size_Cube = Size_Layer * Size_Y; //Number of LEDs whole Cube.
const int Size_CW = ((1 << BAM_RESOLUTION) - 1) * 6; //Number of steps in colour wheel. Why x 6, cos any more will give repeat colours.
void LED(int CY, int CX, int CZ, int CR, int CG, int CB) { //****LED Routine****LED Routine****LED Routine****LED Routine
// First, check and make sure nothing went beyond the limits, Limits are either 0 or Size of the Y,X,Z axis -1 for locations, and 0 or Bam_Resolution - 1 for brightness/colour
CY = constrain(CY, 0, Size_Y - 1);//Cube Y axis
CX = constrain(CX, 0, Size_X - 1);//Cube X axis
CZ = constrain(CZ, 0, Size_Z - 1);//Cube Y axis
CR = constrain(CR, 0, (1 << BAM_RESOLUTION) - 1); //Cube Red
CG = constrain(CG, 0, (1 << BAM_RESOLUTION) - 1); //Cube Green
CB = constrain(CB, 0, (1 << BAM_RESOLUTION) - 1); //Cube Blue
//There are Y * X * Z LEDs (Size_Cube) in the cube, so when if we write to level (Y) 2, panel (X) 5, row 4 (Z), that needs to be translated into a number from 0 to Size_Cube then devided by the number of bits per byte
// Since we use an integer we are left with the byte number, the remainder is dropped off. EG (2*64 + 5*8 + 4)/8 = 21.5, the int of this is WhichByte number 21.(Assuming a cube 8*8*8 LEDs)
int WhichByte = (CY * Size_Layer + CX * Size_X + CZ) / 8;
// This next variable is the same thing as before except we don't devide by 8, so we get the LED number 0 to Size_Cube.
//Then we find which bit of the byte is required. EG (From Above) (2*64 + 5*8 + 4) = LED# 172 - (8 * WhichByte) = 4
int WhichBit = (CY * Size_Layer + CX * Size_X + CZ) - (8 * WhichByte) ;
// So WhichByte 21 WhichBit 4 is the location we will write too for LED 172.
//Now we write to our Cube array if Red, Green and Blue are on or off, using Bit angular modulation.
for (byte I = 0; I < BAM_RESOLUTION; I++) {
//*** RED ***
bitWrite(red[I][WhichByte], WhichBit, bitRead(CR, I));
//*** GREEN ***
bitWrite(green[I][WhichByte], WhichBit, bitRead(CG, I));
//*** BLUE ***
bitWrite(blue[I][WhichByte], WhichBit, bitRead(CB, I));
}
}//****LED ROUTINE END****
Colours. I picked 4 bit colour. Why? Well it made sense at first. I see others with 8 bit and 6 bit colour.
4 bit colour will give you a possible 4096 colours. Straight up you can see that this is a fair few colours for your cube. Remember that more colour requires more memory, but that is not why I recommend 3 bit colour. If you look at Animation code that incorporate colour wheels (As mine does) you will see that the code will make a step change to next colour of 20 to 100 or more steps at a time.
This is cos each one step change is so slight that you don’t see the change. So why have 16.8 million colours when you are only going to use around 100 or so. My colour wheel generates 90 colours, and I still use steps of 10 or more, so 3 bit colour make lots of sense for you cube.
Check out my colour wheel spread sheet. Cell B1 is where you input the bam resolution of you cube. I’m using 4 bit (15 possibilities per colour). Then press “Update Colour wheel”( I couldn’t get that to auto update.) .) ** If you want a copy of the colour wheel Spread sheet, just ask. Not allowed to attach/upload here.
I have code for Mega and Due, if you want it just let me know.


