Error when compiling my 4x4x4 cube code

Hi all.
I have been sneaking around on the site for a year now and have been working with smaller arduino circuit doing that time.

I have just started my first “bigger” DIY projekt. A 4x4x4 LedCube.

I will run the cube with 2 Shift register for the positive site of the 16 leds in each layer, and 4 NPN transistors for the ground site of the Leds.

I have started making my code with just some of the leds on for test.

When I was trying to compile the code I got the following error:

_4x4x4:43: error: integer constant is too large for ‘long’ type

If I make the following change it will compile without error.

The line:
layer[3] = 0000111100001111, BIN;
is changed to
layer[3] = 000011110001111, BIN;

I dont get any errors on the other layer int. why?

Thanks in advance :wink:

Here is my code.

// 4x4x4 LedCube Ver. 0.1

// Connection for the first Shift Register
int latchPin = 11;
int dataPin = 12;
int clockPin = 13;

// Layerpin is the 4 digital output where the 4 transistors are connected.
// On = that layer is connected to ground
int layerPin[4] = {6, 7, 8, 9};

// Int for storing the binary data for each layer - 1 frame
unsigned int layer[4];

// Int that holds the data that's going to be shifted out
int dataOut;

//delays
int layerDelay = 10;
int frameDelay = 100;

void setup()
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  
  digitalWrite(latchPin, LOW);
  digitalWrite(dataPin, LOW);
  digitalWrite(clockPin, LOW);
  
  dataOut = 0000000000000000, BIN;
  shiftOut(dataOut);
  digitalWrite(latchPin, HIGH);
}

void loop()
{
  // Hardcode the animation
  layer[0] = 0000000100000001, BIN;
  layer[1] = 0000001100000011, BIN;
  layer[2] = 0000011100000111, BIN;
  layer[3] = 0000111100001111, BIN;
  
  // Send all layers to shiftOut()
  for (int i=0; i<=3; i++)
  {
    digitalWrite(latchPin, LOW);
    shiftOut(layer[i]);
    digitalWrite(layerPin[i], LOW);
    digitalWrite(latchPin, HIGH);
    digitalWrite(layerPin[i], HIGH);
    delay(layerDelay); // Small delay between each layer
  }
  delay(frameDelay); // Delay between each frame
}

void shiftOut(int data)
{
  // Shift out 16 bit LSBF on rising egde
  // If you want MSBF change the code to 1>>i instead if 1<<i
  boolean pinState;
  
  // Set data and clock pin low and ready for shifting
  digitalWrite(dataPin, LOW);
  digitalWrite(clockPin, LOW);
  
  // For each bit in "data" send out a bit
  for (int i=0; i<=15; i++)
  {
   //set clockPin to LOW prior to sending bit
    digitalWrite(clockPin, LOW);
   // if the value of DataOut and (logical AND) a bitmask
   // are true, set pinState to 1 (HIGH)
    if ( dataOut & (1<<i) )
    {
      pinState = HIGH;
    }
    else
    {
      pinState = LOW;
    }
    //sets dataPin to HIGH or LOW depending on pinState
  digitalWrite(dataPin, pinState);
  //send bit out on rising edge of clock
  digitalWrite(clockPin, HIGH);
  }
//stop shifting out data
digitalWrite(clockPin, LOW);
}

Additional information:
Arduino Uno with IDE 0022 on a MacBook Pro OSX Lion

One more note:

If you guys have other comments on my code, please let me know.

Im a big noob in this exciting world of Arduino ;)

/ Shhh

You don't define a binary constant like that. Even if you could it only works for 8 bit values according to this:- http://www.arduino.cc/en/Reference/IntegerConstants

Okay.

So instead of

layer[3] = 0000111100001111, BIN;

I have to do this?

layer[3] = (B00001111 * 256) + B00001111

/Shhh

Yes, but why use binary hex is much simpler

layer[3] = (B00001111 * 256) + B00001111

is just

layer[3] = 0x0F0F

Or you could use an unsigned int binary constant:

layer[3] = 0b0000111100001111u;

I have never fully understand the HEX system, but maybe now the time is come? :wink:

I think I Will try the unsigned int binary solution first, and when my code is up running, The plan is to code a Python program to make som more advance controlling (Sound controlled etc) here I might try to work with the HEX system!

Thanks for The reply

/shhh