-
 #include <SPI.h>
 #include "nRF24L01.h"
 #include "RF24.h"

  bool done;
  byte n;
  byte i;
  
  strip.setPixelColor(0, strip.Color(255,0,0));
  strip.setPixelColor(1, strip.Color(0,255,0));
  strip.setPixelColor(2, strip.Color(0,0,255));
  strip.setPixelColor(3, strip.Color(0,255,255));
  strip.show();
  
  while(1){
    done = false;
    switch (pattern){

      case 0:  // display r, g and b from master
      while(!done){
        red = msg[14];
        green = msg[15];
        blue = msg[16];
        strip.setPixelColor(0, strip.Color(red, green, blue));
        strip.setPixelColor(1, strip.Color(red, green, blue));
        strip.setPixelColor(2, strip.Color(red, green, blue));
        strip.setPixelColor(3, strip.Color(red, green, blue));
        strip.show();
        //delay(rate);      
        if(check_radio()){done = process_msg();}   
        if (millis() > timeout){
          timeout = millis()+60000;
          pattern = 2;
          done = true;
        }  
      }
      break;
 
     case 1:  // color rotating around circle
      n = (addr-1) * 16;
      while (!done){
        if (n<16){
          strip.setPixelColor(0, strip.Color(255,0,0));
          strip.setPixelColor(1, strip.Color(255,0,0));
          strip.setPixelColor(2, strip.Color(255,0,0));
          strip.setPixelColor(3, strip.Color(255,0,0));
          strip.show();          
        }
        else
        {
          strip.setPixelColor(0, strip.Color(0,0,255));
          strip.setPixelColor(1, strip.Color(0,0,255));
          strip.setPixelColor(2, strip.Color(0,0,255));
          strip.setPixelColor(3, strip.Color(0,0,255));
          strip.show();
        }
        n++;
        if(check_radio()){done = process_msg();}
        if (millis() > timeout){
          timeout = millis()+60000;
          pattern = 2;
          done = true;
        }  
        delay(rate);
      }
      break;

     case 2:  // rainbow rotating around
      n = (addr-1) * 16;
      while (!done){
          for(i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, Wheel((64 + n) & 255));
          }
          strip.show();
          delay(rate);
        n++;
        if(check_radio()){done = process_msg();}
        if (millis() > timeout){
          timeout = millis()+60000;
          pattern = 2;
          done = true;
        }  
        delay(rate);
      }     
      break;

     default:
      pattern = 2;
    }
  
  }
  
}

// Input a value 0 to 255 to get a color value.

  switch (cmnd){
    case 'P':    // set pattern number
      if (msg[3] != pattern){  // new pattern
        pattern = msg[3];
        return true;
      }
      else{
        return false;
      }
      break;
    case 'S':    // set speed of the pattern
      rate = msg[3];
      return false;
      break;
    default:
      return false;
  }
