Color Fading Mode Switching

Here's what I got:

#include <Conceptinetics.h>

boolean button[]= {3,4,5,6,7}; //pin assignment for buttons

boolean buttonstate = 0;


// Color arrays
int black[3]  = { 0, 0, 0 };
int white[3]  = { 100, 100, 100 };
int red[3]    = { 100, 0, 0 };
int green[3]  = { 0, 100, 0 };
int blue[3]   = { 0, 0, 100 };
int yellow[3] = { 100, 50, 0 };
int orange[3] = { 100, 25, 0 };
int purple[3] = { 80, 0, 100};
int pink [3]  = { 100, 0, 45};
int teal [3]  = { 0, 70, 100};

// Set initial color
int redVal = black[0];
int grnVal = black[1]; 
int bluVal = black[2];

int wait = 5;      // 10ms internal crossFade delay; increase for slower fades
int hold = 200;       // Optional hold when a color is complete, before the next crossFade
int DEBUG = 1;      // DEBUG counter; if set to 1, will write values back via serial
int loopCount = 60; // How often should DEBUG report?
int repeat = 0;     // How many times should we loop before stopping? (0 for no stop)
int j = 0;          // Loop counter for repeat

// Initialize color variables
int prevR = redVal;
int prevG = grnVal;
int prevB = bluVal;

DMX_Master dmx_master (512,2);  //DMX Initialize

  void setup()
  {
  for(int x=0; x<5; x++) //starts a loop to set the pin modes for all button pins
  {
    pinMode(button[x], INPUT);
  }
  for(int x=0; x<5; x++) //starts a loop to set the buttons to a default of HIGH
  {
    pinMode(button[x], LOW);
  }
   pinMode (2,OUTPUT);     //This is for the DMX Shield
   dmx_master.enable ();
  }
 
  void loop()
  {
    
    buttonCheck(); //calls to the void buttonCheck() section for checking the buttons
    
    int mode = buttonCheck();
    
    if(mode == 1)
    {
      mode1(); //directs the program to the mode
    }
    if(mode == 2)
    {
      mode2(); //directs the program to the mode
    }
    if(mode == 3)
    {
      mode3(); //directs the program to the mode
    }
    if(mode == 4)
    {
      mode4(); //directs the program to the mode
    }
    if(mode == 5)
    {
      mode5(); //directs the program to the mode
    }   
  }
 
 int buttonCheck()
 {
   int whichWasPressed = -1;
   for(int x=0; x<5; x++) //loop for checking all the buttons
   {
      int buttonstate = digitalRead(button[x]);
      if(buttonstate == HIGH)
      {
          whichWasPressed = x;
      }
   }
   return whichWasPressed;
 }
 
  void mode1() //RGB FADE
  {
    //flash your LEDs how you want in here for this mode
    //a call to buttonCheck can be added in anywhere you want
    //so that the program can continue to check for a button
    //press even while it's in the middle of the mode.
    //When a button is pressed it stores what mode it needs to
    //go to next and will move to that mode once the sequence is over.
    if(buttonCheck()>0) return;
    
    crossFade(red);
    if(buttonCheck()>0) return;
    crossFade(orange);
    if(buttonCheck()>0) return;
    crossFade(yellow);
    if(buttonCheck()>0) return;
    crossFade(green);
    if(buttonCheck()>0) return;
    crossFade(teal);
    if(buttonCheck()>0) return;
    crossFade(blue);
    if(buttonCheck()>0) return;
    crossFade(purple);
    if(buttonCheck()>0) return;
    crossFade(pink);
    
    if(buttonCheck()>0) return;
  
    if (repeat) { // Do we loop a finite number of times?
      j += 1;
      if (j >= repeat) { // Are we there yet?
        exit(j);         // If so, stop.
      }
    }

  }
 
  void mode2() //BLACKOUT
  { 
    //flash your LEDs how you want in here for this mode
    //a call to buttonCheck can be added in anywhere you want
    //so that the program can continue to check for a button
    //press even while it's in the middle of the mode.
    //When a button is pressed it stores what mode it needs to
    //go to next and will move to that mode once the sequence is over.
    if(buttonCheck()>0) return;
    dmx_master.setChannelValue (1,0);
    dmx_master.setChannelValue (2,0);
    dmx_master.setChannelValue (3,0);
    if(buttonCheck()>0) return;
        
  }
 
  void mode3() //ALL@FULL
  {
    //flash your LEDs how you want in here for this mode
    //a call to buttonCheck can be added in anywhere you want
    //so that the program can continue to check for a button
    //press even while it's in the middle of the mode.
    //When a button is pressed it stores what mode it needs to
    //go to next and will move to that mode once the sequence is over.
    if(buttonCheck()>0) return;
    dmx_master.setChannelValue (1,255);
    dmx_master.setChannelValue (2,255);
    dmx_master.setChannelValue (3,255);
    if(buttonCheck()>0) return;
  } 
  void mode4()
  {
    if(buttonCheck()>0) return;
  }
 
  void mode5()
  {
     if(buttonCheck()>0) return;  
  }
  
//LED FADE PROGRAM ...................................................................................
//...

// April 2007, Clay Shirky <clay.shirky@nyu.edu> 
 
  

  int calculateStep(int prevValue, int endValue) {
  int step = endValue - prevValue; // What's the overall gap?
  if (step) {                      // If its non-zero, 
  step = 1020/step;              //   divide by 1020
  } 
  return step;
  }

  /* The next function is calculateVal. When the loop value, i,
  *  reaches the step size appropriate for one of the
  *  colors, it increases or decreases the value of that color by 1. 
  *  (R, G, and B are each calculated separately.)
  */

  int calculateVal(int step, int val, int i) 
  {

  if ((step) && i % step == 0) { // If step is non-zero and its time to change a value,
    if (step > 0) {              //   increment the value if step is positive...
      val += 1;           
    } 
    else if (step < 0) {         //   ...or decrement it if step is negative
      val -= 1;
    } 
  }
 
  // Defensive driving: make sure val stays in the range 0-255
  if (val > 255) 
  {
    val = 255;
  } 
  else if (val < 0) {
    val = 0;
  }
  return val;
  }

  /* crossFade() converts the percentage colors to a 
  *  0-255 range, then loops 1020 times, checking to see if  
  *  the value needs to be updated each time, then writing  
  *  the color values to the correct pins.
  */

  void crossFade(int color[3])
  {
  // Convert to 0-255
  int R = (color[0] * 255) / 100;
  int G = (color[1] * 255) / 100;
  int B = (color[2] * 255) / 100;
  
  int stepR = calculateStep(prevR, R);
  int stepG = calculateStep(prevG, G); 
  int stepB = calculateStep(prevB, B);
  
  
    

  for (int i = 0; i <= 1020; i++) {
    redVal = calculateVal(stepR, redVal, i);
    grnVal = calculateVal(stepG, grnVal, i);
    bluVal = calculateVal(stepB, bluVal, i);
    buttonCheck();
    dmx_master.setChannelValue (1, redVal);   // Write current values to LED pins (DMX Channels)
    dmx_master.setChannelValue (2, grnVal);      
    dmx_master.setChannelValue (3, bluVal); 
    
   
    

    delay(wait); // Pause for 'wait' milliseconds before resuming the loop

    
  }

  // Update current values for next loop
  prevR = redVal; 
  prevG = grnVal; 
  prevB = bluVal;
  delay(hold); // Pause for optional 'wait' milliseconds before resuming the loop
  }

How's this look? It doesn't seem to interrupt the fading, and the wrong button now starts the fade. I played with the -1, but I never got it to work.