neopixel code issue

Hi all
Im trying to make a “fancy” light to go on a flag pole when we are camping in the caravan. Im currently testing using a 1m 30led strip and want it to create different patterns and randomise them. I have some patterns done mainly from the strandtest code with a few changes here and there. I’ve seen the code on adafruits site that looks like the light from knight rider and i also have some code from the fast led library where the led goes one way then bounces back. when it reaches the start it changes colour and repeats. I want this colour change on the knight rider type one but just cant get it to work.

If anyone has other cool patterns that would not mind sharing that would be good. Its going to be a 5 meter strip in the end.

This is the adafruit code.

#include <Adafruit_NeoPixel.h>

#define N_LEDS 30
#define PIN     6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
}

int pos = 0, dir = 1; // Position, direction of "eye"

void loop() {
  int j;

  // Draw 5 pixels centered on pos.  setPixelColor() will clip any
  // pixels off the ends of the strip, we don't need to watch for that.
 
  //strip.setPixelColor(pos - 2, 16,0,0); // Dark red
  //strip.setPixelColor(pos - 1, 128,0,0); // Medium red
  //strip.setPixelColor(pos    , 255,48,0); // Center pixel is brightest
  //strip.setPixelColor(pos - 1, 128,0,0); // Medium red
  //strip.setPixelColor(pos - 2, 16,0,0); // Dark red
  
  //strip.setPixelColor(pos - 2, 255,10,0); // Dark red
  //strip.setPixelColor(pos - 1, 0,255,0); // Medium red
  //strip.setPixelColor(pos    , 0,150,255); // Center pixel is brightest
  //strip.setPixelColor(pos - 1, 0,255,0); // Medium red
  //strip.setPixelColor(pos - 2, 255,10,0); // Dark red
  
  strip.setPixelColor(pos - 2, 0x100000); // Dark red
  strip.setPixelColor(pos - 1, 0x800000); // Medium red
  strip.setPixelColor(pos    , 0xFF3000); // Center pixel is brightest
  strip.setPixelColor(pos + 1, 0x800000); // Medium red
  strip.setPixelColor(pos + 2, 0x100000); // Dark red

  strip.show();
  delay(30);

  // Rather than being sneaky and erasing just the tail pixel,
  // it's easier to erase it all and draw a new one next time.
  for(j=-2; j<= 2; j++) strip.setPixelColor(pos+j, 0);

  // Bounce off ends of strip
  pos += dir;
  if(pos < 0) {
    pos = 1;
    dir = -dir;
  } else if(pos >= strip.numPixels()) {
    pos = strip.numPixels() - 2;
    dir = -dir;
  }
}

This is the led bounce code.

    #include <FastLED.h>
    #define NUM_LEDS 30
    #define DATA_PIN 6
   
CRGB leds[NUM_LEDS]; 

   void setup() { 
       FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
   }
   
void loop() { 
	// First slide the led in one direction
	for(int i = 0; i < NUM_LEDS; i++) {
		// Set the i'th led to red 
		leds[i] = CRGB::Red;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(30);
	}

	// Now go in the other direction.  
	for(int i = NUM_LEDS-1; i >= 0; i--) {
		// Set the i'th led to red 
		leds[i] = CRGB::Red;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(30);
	}

// First slide the led in one direction
	for(int i = 0; i < NUM_LEDS; i++) {
		// Set the i'th led to red 
		leds[i] = CRGB::Green;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(30);
	}

	// Now go in the other direction.  
	for(int i = NUM_LEDS-1; i >= 0; i--) {
		// Set the i'th led to red 
		leds[i] = CRGB::Green;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(30);
	}

// First slide the led in one direction
	for(int i = 0; i < NUM_LEDS; i++) {
		// Set the i'th led to red 
		leds[i] = CRGB::Blue;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(30);
	}

	// Now go in the other direction.  
	for(int i = NUM_LEDS-1; i >= 0; i--) {
		// Set the i'th led to red 
		leds[i] = CRGB::Blue;
		// Show the leds
		FastLED.show();
		// now that we've shown the leds, reset the i'th led to black
		leds[i] = CRGB::Black;
		// Wait a little bit before we loop around and do it again
		delay(30);
	}
}

Thanks
Lee

A little bit more information on what you want it to look like please.

I'm guessing that you want the Larson Scanner effect? Look at the Cyclon example that comes with the FastLed library.

5 metre strip? How many leds per metre? You need to consider the memory the array(s) will use.

Hi all.
The first bit of code above is the larson scanner code from the adafruit site with a bit of my mess in it that I forgot to remove before posting. The second bit is from the FastLED library which sends a red led down the strip and it bounces back once it hits the end. when it gets to the start it changes to green and then blue. I can add any colour I like but im wanting this colour option but using the adafruit neopixel library like the larson code.

Dannable
it would be 5 meter at 30 led/m. Power is my other issue but that's a lot simpler to fix.

My goal is to have a long strip that can randomly show effects like the ones from the strandtest but also include anything I can come up with and other effects I find that others have done. This being one. Another effect I have seen and like is the detonation effect shown on the site below.

But I cant get it to work on my uno and picking just that code out with how hes done it i've no chance yet until I understand the coding more.
Hope that helps explain it a bit more

Lee