title: lighting two ends of LED strip using Arduino fastLED library
body: <p>I have a LED strip(WS2812B) of 60 LED's. I have the following code which lights up a LED at the beginning of the strip and sends it down to the end, once it reaches the end it 'bounces back' and returns down the strip to the start.</p>
  
  <p>What I'm trying to do is to have both ends of the LED strip light up with a led and a small trail behind it, these LED's then move down the strip to the opposite ends and cross over when they meet.</p>
  
  <p>I'm trying to figure out how to run two lines of code at once, as currently it sends the lights down one way, then it runs the other code. Any help would be appreciated </p>
  
  <p>Below is my code so far.</p>
  
  <pre><code>#include "FastLED.h"
  
  // How many leds in your strip?
  #define NUM_LEDS 57
  
  // For led chips like Neopixels, which have a data line, ground, and power, you just
  // need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
  // ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
  #define DATA_PIN 4
  #define CLOCK_PIN 13
  
  // Define the array of leds
  CRGB leds[NUM_LEDS];
  int end_led = 55;
  void setup() { 
      FastLED.addLeds&lt;NEOPIXEL, DATA_PIN&gt;(leds, NUM_LEDS);
  }
  
  void loop() { 
  
      // First slide the led in one direction
      for(int i = 0; i &lt; NUM_LEDS; i++) {
          // Set the i'th led to
          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 &gt;= 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);
      }
  </code></pre>
  
  <p>}</p>