3by3 led cube control by matrix not working

I have made a Led cube got it working i have programed it but i wanna move to the next step of saving the image of each pattern as a byte array.....
i couldn't use byte because it only accepts 8 values and i have 9 leds.. I wrote the arrays as ints instead but when i upload it nothing happens to the cube..(power shows on mega just the cube doesnt work).

If there is a way to still do it with bytes that may help if it has any advantages working with bytes..

i tried to write some code but nothing happens here it is...

int levelPins[] = {22,23,24};
int colPins[] = {30,31,32,33,34,35,36,37,38};

int first[3][9] = {
111000000,
011100000,
001110000,
};

void setup () {
  //set all output
  for (int i=0; i<3; i++) {
    pinMode(levelPins[i], OUTPUT);
  }
  for (int j=0; j<9; j++) {
    pinMode(colPins[j], OUTPUT);

  }
}

void show (int image[3][9]) {
 for (int level=0; level<3; level++) {
  digitalWrite(levelPins[level], LOW);
   
   for (int col=0; col < 9; col++) {
    int pixel = image[level][col];
    
  if (pixel == 1) {digitalWrite(colPins[col], HIGH);}
 
 delay(30);
 digitalWrite(colPins[col], LOW);
       } // col for
   digitalWrite(levelPins[level], HIGH);
   } // level for
 } // end of show


void loop() {

show(first);
  }

Here is a video of the working led cube without images saved as arrays.. that code is somewhere in ...http://arduino.cc/forum/index.php/topic,69174.0.html
Led cube setup - YouTube

int first[3][9] = {
111000000,
011100000,
001110000,
};

This isn't an array of three rows of nine ints, it's an array of three ints, try this:

int first[3] = {
111000000,
011100000,
001110000,
};

Then you need to modify your "show()" function to look at the the individual bits in each int:

void show (int image[3]) {
 for (int level=0; level<3; level++) {
  digitalWrite(levelPins[level], LOW);
   
   for (int col=0; col < 9; col++) {
    int bitmask = 1<<col;
    int pixel = image[level]&bitMask;

    if (pixel != 0) {digitalWrite(colPins[col], HIGH);}
...

fungus:

int first[3][9] = {

111000000,
011100000,
001110000,
};




This isn't an array of three rows of nine ints, it's an array of three ints, try this:

So will declaring ,
111000000,
011100000,
001110000,
without the [9] make 3 arrays size 9? what was wrong with the first 1 i dnt get it but i will try ur method, i just want to understand what im doing. Thx for the reply.

also i dont understand this bit

for (int col=0; col < 9; col++) {
    int bitmask = 1<<col;
    int pixel = image[level]&bitMask;

That part of the code takes the value in image[level] and splits it into it's individual bits and places them one by one in the variable pixel.
The << is a shift operation and the & is a logical AND.
The logical AND with the bit mask sets all the bits to zero apart from the bits in the bit mask.
The << shifts the bitmask one place to the left each time round the loop.

111000000,
011100000,
001110000,

Why are some constants in decimal, and others in octal?

AWOL:

111000000,
011100000,
001110000,

Why are some constants in decimal, and others in octal?

Umm... I have no idea what you are talking about so i guess i got some reading to do.

What i was trying to achieve is each line represents a level on my cube each 1 or 0 represents the led in that levels status.
so "011100000" represents 1st led off second on third on fourth on... ect..

so "011100000" represents 1st led off second on third on fourth on... ect.

In C, a constant starting with a zero is taken to be an octal value, in this case, the equivalent decimal value is 2 392 064.

If you want a binary constant, prefix the number with "0b".

AWOL:

so "011100000" represents 1st led off second on third on fourth on... ect.

In C, a constant starting with a zero is taken to be an octal value, in this case, the equivalent decimal value is 2 392 064.

If you want a binary constant, prefix the number with "0b".

I just realized what i was doing wrong with my original code.....
i declared my array wrong

int first[3][9] = {
111000000,
011100000,
001110000,
};

Should have been ...

int first[3][9] = {
{1, 1, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0, 0, 0},
};

if i want declare them as bytes i should do this?

int first[3]= {
0b111000000,
0b011100000,
0b001110000,
};

do i have to change the array type to byte? also i tried this method but used the "B" prefix and it only let me use upto 8 numbers.. i have 9 leds so thats a problem.

used the "B" prefix and it only let me use upto 8 numbers

If you need 9 bits, use "0b" as the prefix.
See reply #7.
The "B" prefix is an Arduino convenience.