Attempting to move a group of pixels down a LED strip

Hello all
I'm attempting to move a group of 3 pixels down an LED strip. I can successfully send 1 down and continue repeating. However, when changing [i] to [i + 3], I thought I would see 3 pixels traveling down. But not working correctly. Any ideas?

// Use if you want to force the software SPI subsystem to be used for some reason (generally, you don't)
// #define FASTLED_FORCE_SOFTWARE_SPI
// Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things)
// #define FASTLED_FORCE_SOFTWARE_SPI
// #define FASTLED_FORCE_SOFTWARE_PINS
#include <FastLED.h>

///////////////////////////////////////////////////////////////////////////////////////////
//
// Move a white dot along the strip of leds.  This program simply shows how to configure the leds,
// and then how to turn a single pixel white and then off, moving down the line of pixels.
// 

#define NUM_LEDS 70
#define DATA_PIN 5
//#define CLOCK_PIN 13

// This is an array of leds.  One item for each led in your strip.
CRGB leds[NUM_LEDS];

// This function sets up the leds and tells the controller about them
void setup() {
	// sanity check delay - allows reprogramming if accidently blowing power w/leds
   	delay(2000);

    FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
     fill_solid(leds, NUM_LEDS, CRGB::Red); 
}

// This function runs over and over, and is where you do the magic to light
// your leds.
void loop() {

   
   for(int i = NUM_LEDS-1; i >= 0; i--) {
      // Turn our current led on to white, then show the leds
  
     
     leds[i+3] = CRGB::Red; 

      // Show the leds (only one of which is set to white, from above)
      FastLED.show();

      // Wait a little bit
      delay(20);

      // Turn our current led back to black for the next loop around
      leds[i] = CRGB::White;
   }
}

That only turns on makes Red one LED.

You needa do something like

for (int xx = 0; xx < 3; xx++)
    leds[i + xx] = CRGB::Red;

which turns Red the i, i + 1 and i + 2 pixels.

You’ll have to work out how to turn off make Black the LEDs at some point.

Although your code uses White, is that what you meant? Comment sez black.

Looks like you are guessing and experiment. Those have their place and time, but will be a painful means to learning how to program,

a7

Alto777:

You nailed it. Thank you for your help. Yes, you are correct. Been playing around and not updating the comments. I'll clean it up now. I appreciate your hlep.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.