It's probably been done before, but I couldn't find exactly what I wanted,

It’s probably been done before, but I couldn’t find exactly what I wanted, so when I figured it out on my own, I figured I’d share it. Here’s a way to do traveling stripes down the length of your LED strip without using a delay (the millis method). I’m using a Particle Photon board to drive the strip so declarations might vary slightly, but the math should be sound. If there’s a better way, I’m all ears.

int offset = 0;

void newCane(){
int numColors = 2;
int stripeLength = 10;
int travelSpeed = 75;
int color1 = CRGB::White;
int color2 = CRGB::Red;

if (currentMillis - previousMillis >= travelSpeed) {
previousMillis = currentMillis;
    for(int i=0;i<NUM_LEDS;i++){
        if( (i+offset)%(numColors*stripeLength)<stripeLength+1 ){
            leds[i] = color2;
            leds[i] = color1;
        if(offset>=NUM_LEDS) offset = 0;


void loop()
currentMillis = millis();

I’m so glad your canes aren’t going to be stripeless. I like it, nice solution.

Nice! here is how I do it more generically (also with a Photon) – this takes whatever pattern is currently on the lights and chases it, with a configurable step size. It suffers from some edge effects sometimes, but generally works:

int patternDelay;
int chaseStepSize;

void loop(){
if (doChase) {
EVERY_N_MILLIS_I(chaseTimer, patternDelay) {

void chase(){
// Set the first few LEDs to whatever is at the end of the strip
for(uint16_t i=0; i<(chaseStepSize); i++) {
leds[i] = leds[numLEDs - 1 - chaseStepSize + i];

// Then work your way from the end of the strip towards the front
for(uint16_t i=(numLEDs-1); i>chaseStepSize-1; i--) {
  leds[i] = leds[i - chaseStepSize];