 
 //---------------------------------------------------------------
 void loop() {
-    // Set first 4 pixels with the pattern we want to repeat.
-    fill_rainbow(leds, 4, millis()/20, 20);
-
-    // Copy the pixel data down the rest of the strip.
-    CopyPixels();
-    
-    FastLED.show();  //display leds
-
+  
+  repeatingPattern();
+  FastLED.show();
 
 }//end_main_loop
 
 
 //---------------------------------------------------------------
-void CopyPixels() {
-  // Copy pixel data from frist 4 pixels to rest of strip.
+void repeatingPattern() {
+  // Every so often pick a new random pattern length
+  EVERY_N_SECONDS(7) {
+    FastLED.clear();
+    random16_add_entropy(random16() + random());
+    patternLength = random8(3,11);
+    pRepeat = NUM_LEDS / patternLength;
+    pDiff = NUM_LEDS % patternLength;
+    Serial.print("patternLength: "); Serial.print(patternLength);
+    Serial.print("\tpDiff: "); Serial.print(NUM_LEDS); Serial.print(" % "); Serial.print(patternLength);
+    Serial.print(" = "); Serial.println(pDiff);
+  }
 
-  for (uint8_t i=0; i < NUM_LEDS/4; i++) {
-    memmove8( &leds[i*4], &leds[0], (4)*sizeof(CRGB) );
+  // Set first n pixels with the pattern to repeat
+  fill_rainbow( leds, patternLength, millis()/100, 15 );
+
+  // Set first pixel in pattern white to easily see where pattern restarts/repeats
+  leds[0] = CHSV(0,0,200);
+  
+  // Copy pixel data from first n pixels to rest of strip using memmove8
+  // Syntax for memmove8:
+  //   memmove8( &destination[start position], &source[start position], size of pixel data )
+  for (uint8_t i=0; i < pRepeat; i++) {
+    memmove8( &leds[i*patternLength], &leds[0], (patternLength)*sizeof(CRGB) );
+  }
+
+  // Copy remainder pixels at end of strip if needed
+  if (pDiff != 0) {
+    memmove8( &leds[NUM_LEDS - pDiff], &leds[0], (pDiff)*sizeof(CRGB) );
   }
 
 }//end_CopyPixels
 
-
 //---------------------------------------------------------------
-// Reminder of the memmove8 format:
-//   memmove8( &destination[start position], &source[start position], size of pixel data )
-//---------------------------------------------------------------
-

#define NUM_LEDS 32

CRGB leds[NUM_LEDS];


//---------------------------------------------------------------

//***************************************************************
// Example of using memmove8 to copy/repeat pixel data down strip.
//
// Random pattern lengths are picks and then then the first n pixels
// are filled with color data.  The pattern is then copied/repeated
// down the length of the strip using memmove8.  If the pattern
// length doesn't divide into NUM_LEDS as a whole number then the
// last few pixels are copied separately.
//
// The snytax for memmove8 is:
// memmove8( &destination[start position], &source[start position], size of pixel data )
