two running lights in on stripe from the middle

Hello,

at first i must say my english is not the best and i´m not the expert in Arduino and ESP8266.
Here is my Problem
i have 5m Neopixel LED Stripe with 300 Neopixel and a D1 Mini with ESP8266. I want to have two running light from the middle all the way out. both start simultaneously in the middle, one goes right, one goes left.
but i don´t know how. :frowning:

here is my code, but it doen´t works, what is the problem?:

#include <Adafruit_NeoPixel.h>
#ifdef AVR
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define LED_PIN D5
#define LED_COUNT 300

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
#if defined(AVR_ATtiny85) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif

strip.begin();
strip.show();
strip.setBrightness(50);

}

void loop() {
colorWipe(strip.Color(200, 100, 255), 1); // Red
colorWipe(strip.Color( 0, 60, 150), 15); // Green
colorWipe(strip.Color( 200, 40, 200), 25); // Blue

}

void colorWipe(uint32_t color, int wait) {
for (int j=150; j<strip.numPixels(); j++) {
strip.setPixelColor(j, color); // Set pixel’s color (in RAM)

for (int i=149; i>0; i–) {
strip.setPixelColor(i, color); //
strip.show(); // Update strip to match
// Pause for a moment
}
}
}

i hope you can understand my problem.

thanks for help

best regards :slight_smile:
Oliver

You use two variables to indicate what LED number you want to light up and set them up to initially be at the center LED or LEDs of the strip.

You use a for loop structure, to cover half the number of LEDs you have. Each time round the loop increment one and decrement the other.
You then light up the one LED from each variable and call the show method.

ok thank you
i will try it

I recently did something very similar to the OP’s project. It’s not perfect but it goes fast enough that the viewer doesn’t see the dichotomy at the start, and I don’t test that both ends were addressed. But it may help the OP.

#define SKETCH "DivergingLEDs.ino"

#include <FastLED.h>

#define LED_PIN    D2
#define NUM_LEDS 85
#define LED_TYPE WS2811
#define COLOR_ORDER RGB
#define BRIGHTNESS 50

CRGB leds[NUM_LEDS];

int x, y;

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println(F(SKETCH));

  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(BRIGHTNESS);

  // Start with all LEDs off.
  fill_solid (leds, NUM_LEDS, CRGB::Black);
  FastLED.show();
  delay(100);
}


void loop() {
  x = NUM_LEDS / 2;
  y = (NUM_LEDS / 2) + 1;

  for (int i = 0; x <= NUM_LEDS; i++) {

    Serial.print(F("i= "));
    Serial.print(i);
    Serial.print(F("    x= "));
    Serial.print(x++);
    Serial.print(F("    y= "));
    Serial.println(y--);

    leds[x] = CRGB::Blue;
    leds[y] = CRGB::Blue;
    FastLED.show();
    delay(25);
    leds[x] = CRGB::Black;              // Set to black for next loop iteration
    leds[y] = CRGB::Black;
  }
}

It's not perfect but it goes fast enough

It will run a hell of a lot faster when you remove all those print statements.

Grumpy_Mike:
It will run a hell of a lot faster when you remove all those print statements.

The print statements are just for development to make sure all leds were addressed. That's where I saw the problems mentioned above.

Steve