Led cube and IR remote code not working together

Hi, I’ve been working on my first 5x5x5 LED cube, And everything worked out well.
The thing if I tried to add support for a remote so I could control the brightness and and change animation.
The cube works fine until I use the remote… Then it freezes.
The ir remote uses timer 2, and the updating process of my cube uses timer one, so I don’t think the problem would come from there.
Here’s my code:

*  This code mostly comes from Kevin Darrah's code for it's 8x8x8 rgb led cube
 www.kevindarrah.com
 */
#include <SchedulerARMAVR.h>//for handeling the execution of the animations and recieving 
#include <IRremote.h>//These two includes are for the IR remote
#include <IRremoteInt.h>
#include <SPI.h>//SPI for the shift registers
#define latch_pin 2
#define RECV_PIN 10
//byte ledMap[5][25];
byte num_anim=5;// number of animations I wrote for the moment
byte BAMcounter=0;// These two counters are needed for the bit angle modulation
byte BAMbit=0;//
byte data[5][4][4];// These  bytes hold the data send to the shift registers
//the first "dimention" represent the levels, the second one contains the bits matching each 
//connection out of the shift registers and the third "dimention" is fort each bit of the bit 
//angle modulation
byte level=0;//the level at which we are
byte pwm_max=15;// max luminosity, useful when controling the overall brightness of the cube
char animation=-1;//current animation
char lastanim=0;// animation we where at when the cube is put in sleep mode
//IRrecv reciver(RECV_PIN);// reciver object for the IR remote
//decode_results IRcomand;//object to hold the data from the remote
unsigned long last_comand=0;// in case of continuous press on the remote
void setup() {
  // put your setup code here, to run once:
  randomSeed(39);// intizlize random
  SPI.setBitOrder(MSBFIRST);//config for the spi
  SPI.setDataMode(SPI_MODE0);
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  pinMode(13,OUTPUT);//for spi
  pinMode(11,OUTPUT);//for spi
  pinMode(latch_pin, OUTPUT);//needed to update the led cube
  for(int a=0;a<5;a++)//initialize the data so everything is turned of
    for(int b=0;b<4;b++)
      for(int c=0;c<4;c++)
      {
        data[a][b][c]=0;
      }
  for(int i=0;i<4;i++)//bit masks for the levels
    data[0][3][i]=B00000010;
  for(int i=0;i<4;i++)
    data[1][3][i]=B00000100;
  for(int i=0;i<4;i++)
    data[2][3][i]=B00001000;
  for(int i=0;i<4;i++)
    data[3][3][i]=B00010000;
  for(int i=0;i<4;i++)
    data[4][3][i]=B00100000;//until here

  noInterrupts();//seting up the timer 1, don't want to be interrupted
  TCCR1A=B00000000;//no pwm
  TCCR1B=B00001011;//clock div=64, couter mode
  TIMSK1=B00000010;//interupt on compare A
  OCR1A=25;//play with the valu so the update frequency is high enough 
  //so there is no glitching, but not too high so we still have some cpu time
  SPI.begin();//init spi
  SPI.transfer(0);// clears shift register from all garbage from bootloader
  SPI.transfer(0);
  SPI.transfer(0);
  SPI.transfer(0);
  SPI.transfer(0);
  digitalWrite(2,HIGH);//clear outputs
  digitalWrite(2,LOW);//
  interrupts();// let the show begin
  //reciver.enableIRIn();// starts reciving IR from th remote uses timer 2
  Scheduler.startLoop(humanHandeler);// starts the loop for human interaction
  // Serial.begin(115200);//for debugging
}

void loop() {
  // put your main code here, to run repeatedly: 
  animation++;//go to the next animation
  switch(animation)
  {
  case -2://led cube is sleeping
    for(byte a=0;a<5;a++)//blanks out everything
      for(byte b=0;b<5;b++)
        for(byte c=0;c<5;c++)
          LED(a,b,c,0);
    animation--;
    //keeps the counter from incrementing
    break;
  case 0:
    walls();
    break;
  case 1:
    cross();
  case 2:
    heartGlow();
    break;
  case 3:
    travel();
    break;
  case 4:
    rain();
    break;
  case 5:
    fill();
    break;
  default:
    animation=-1;//if we are over 5, then go back to begining
    break;
  }

  yield();//scheduler control
}

void humanHandeler()//handeling  remote orders
{
  if(reciver.decode(&IRcomand))//did we recived anything?
    if(IRcomand.decode_type==1)//did it came from the good remote?
    {
      switch(IRcomand.value)
      {
      case 0x40BF906F://power
        if(animation!=-2)//not in sleep so let's sleep
        {
          lastanim=animation;//save current animation
          animation=-2;//set -2 so it goes to sleep
        }
        else
          animation=lastanim;//recover from sleep, where we left
        break;
      case 0x40BFB04F://plus
        pwm_max=constrain(pwm_max++,0,15);//increment pwm_max, but not exeding 15 
        break;
      case 0x40BF708F://minus
        pwm_max=constrain(pwm_max--,0,15);//decrement pwm max but not under 0
        break;
      case 0x40BF50AF://left
        animation--;//go one animation back
        if(animation<-1) animation=num_anim-1;//roll over
        break;
      case 0x40BFA857://right
        animation++;//one animation forward
        if(animation>num_anim-1)//roll over
          animation=-1;
        break;
        /*case 0xFFFFFFFF://repeat
         switch(last_comand)//starts over with previous ir code
         {
         case 0x40BF906F:
         if(animation!=-2)
         {
         lastanim=animation;
         animation=-2;
         }
         else
         animation=lastanim;
         break;
         case 0x40BFB04F:
         pwm_max=constrain(pwm_max++,0,15);
         break;
         case 0x40BF708F:
         pwm_max=constrain(pwm_max--,0,15);
         break;
         case 0x40BF50AF:
         animation--;
         if(animation<-1) animation=num_anim-1;
         break;
         case 0x40BFA857:
         animation++;
         if(animation>num_anim-1)
         animation=-1;
         break;
         }
         break;
      default:
        break;
      }
      if(IRcomand.value!=0xFFFFFFFF)//save ir code if not a repeat code
        last_comand=IRcomand.value;
    }

  reciver.resume();// start reciving ir codes again
  yield();//scheduling control
}

void LED(byte x, byte y, byte z, byte pwm)// this function translates the coordiantes of 
//the led and its brightness into the data bytes
{
  if(pwm&B00000001)//checks for first bit of pwm
  {
    bitSet(data[z][(5*y+x)/8][0],(5*y+x)%8);//level if first dimention (z)
    //(5*y+x)/8 returns the byte and (5*y+x)%8 returns the bit
  }
  else{
    bitClear(data[z][(5*y+x)/8][0],(5*y+x)%8);
  }
  if(pwm&B00000010)//check second bit
  {
    bitSet(data[z][(5*y+x)/8][1],(5*y+x)%8);
  }
  else{
    bitClear(data[z][(5*y+x)/8][1],(5*y+x)%8);
  }
  if(pwm&B00000100)//check third bit
  {
    bitSet(data[z][(5*y+x)/8][2],(5*y+x)%8);
  }
  else{
    bitClear(data[z][(5*y+x)/8][2],(5*y+x)%8);
  }
  if(pwm&B00001000)//check fourth bit
  {
    bitSet(data[z][(5*y+x)/8][3],(5*y+x)%8);
  }
  else{
    bitClear(data[z][(5*y+x)/8][3],(5*y+x)%8);
  }
}

ISR(TIMER1_COMPA_vect){//isr, updating the led cube
//here the BAM_counter keeps track of where we are updationg the cube
  if(BAMcounter==4)//when reaching 4, bit one is done
    BAMbit++;//go to next bit
  else
    if(BAMcounter==12)//when reaching 12, bit 2 is done
      BAMbit++;//go to next bit
    else
      if(BAMcounter==28)//when reaching 28, bit 3 is done
        BAMbit++;//go to next bit

  BAMcounter++;//each interrupt increment this couter
  for(byte i=0;i<4;i++)//transfer data bytes to shift register
    SPI.transfer(data[level][3-i][BAMbit]);
  bitSet(PORTD,2);//port manipulation for latching so everything is faster
  bitClear(PORTD,2);
  level++;//level goes up
  if(level==5)//reset level
    level=0;
  if(BAMcounter==72)//rester BAM_counter and BAM_bit
  {
    BAMcounter=0;
    BAMbit=0;
  }

}

I didn’t inculde the animations because they are only a bunch of ‘for’ loops, of ‘LED()’ calls and of ‘Scheduler.delay()’
If somebody find out what could be the problem I would be very grateful :smiley:

Never mind, It was actually a problem in my hardware desing...