My 3x3x3 and 5x5x5 LED cube

Hi Guys!

@Hippynerd: If your cube would have ghosting like mine, you would notice it, trust me :slight_smile: It is very visible and... annoying. Unfortunately I can't create a video as my camera is broken and even for my last video I had to borrow one (I really should get one...), but I can describe it the following way: when multiplexing is used, the ghosting is seen as the previously multiplexed (lit) layer turning off too slowly, so basically you see a ghost image (dim image) of the current layer in the previously lit layer. So, if you light up an LED in the bottom layer, you'll see the LED which is in the same column and in the top layer (bottom layer is lit after the top layer because the layers come after each other from bottom to top) dimly lit. If you light an LED in the second layer, you'll see the LED below it dimly lit. For the third layer the ghost will be in the second layer and so on.

@WonderTiger: Sure, you can check out my code here: http://iqjar.com/download/jar/LED_Cube/4x4x4/LEDQB_v0.4.ZIP
I've taken a slightly different approach. My animations are all generated on the fly, no patterns are stored anywhere. I also put great emphasis into keeping every part of the code in the place where it logically belongs, so I have lots of files and classes. So far it worked out well, we'll see how well it will work with the 8x8x8 cube... The part that writes the data out to the cube is in QBWriter.cpp, in the function QBWriter::sendOutputBuffer(). You'll see there that in the first step I shift all 0s into all the shift registers and then, if there's any non-zero data to be displayed, I first wait for 75 milliseconds (delayMicroseconds (TurnOffLatency); //Wait for everything to turn off). this is a software fix to get rid of the ghosting. I'd like a hardware fix though :frowning:

void QBWriter::sendOutputBuffer () const
{
    //To get around the ghosting introduced by the slow turning off of the cathode columns, we first turn everything off and wait a little
    digitalWrite (PIN_SS, LOW); //Start transferring data    
    for (byte i = 0; i  <= N; ++i)
    {
        SPI.transfer (B00000000);
    }
    digitalWrite (PIN_SS, HIGH); //Done transferring data
    
    if (isOutputDataNonZero ())
    {
        delayMicroseconds (TurnOffLatency); //Wait for everything to turn off
  
        //Then we push out the contents of the output buffer to the LED cube    
        digitalWrite (PIN_SS, LOW); //Start transferring data
        for (byte i = 0; i  <= N; ++i)
        {
            SPI.transfer (mOutputBuffer[i]);
        }
        digitalWrite (PIN_SS, HIGH); //Done transferring data
    }
}