 //***************************************************************
 // Three moving colors.
+//     Uses modulo, %, to make pixel position "loop" around and
+//     stay in valid pixel range.
 //
 // Marc Miller,  Jan. 2019
-//  April 2019 - Updated to use EVERY_N instead of delay().
+//     Apr. 2019 - updated to use EVERY_N instead of delay()
+//     Apr. 2021 - cleaned up some duplicate code
 //***************************************************************
 
 #include "FastLED.h"


//---------------------------------------------------------------
void loop() {

  EVERY_N_MILLISECONDS(holdTime) {

    //set position and color of pixels
    leds[(positionRed + delta + NUM_LEDS) % NUM_LEDS] = CRGB::Red;
    leds[(positionWhite + delta + NUM_LEDS) % NUM_LEDS] = CRGB::Grey;
    leds[(positionBlue + delta + NUM_LEDS) % NUM_LEDS] = CRGB::Blue;
  
    FastLED.show();  //show the pixels
   
    //advance position based on delta, and rollover if needed.
    positionRed = ((positionRed + delta + NUM_LEDS) % NUM_LEDS);
    positionWhite = ((positionWhite + delta + NUM_LEDS) % NUM_LEDS);
    positionBlue = ((positionBlue + delta + NUM_LEDS) % NUM_LEDS);

  }//end_every_n

}//end_main_loop


#define MASTER_BRIGHTNESS 64
CRGB leds[NUM_LEDS];

// Set initial start position of each color
int16_t positionA = NUM_LEDS*2/3;
int16_t positionB = NUM_LEDS/3;
int16_t positionC = 0;

const uint16_t holdTime = 120;  // Adjusts speed of travel
int8_t delta = 1;  // 1 or -1.  Sets travel direction


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