Center Outward Color Wipe

I have an Adafruit 16 Neopixel strip that I’m trying to color wipe from the center outwards toward the ends. <<<<<<<<>>>>>>>> Any help would be appreciated. Thanks in advance.

#include "FastLED.h"
#define NUM_LEDS 60 
CRGB leds[NUM_LEDS];
#define PIN 6 

void setup()
{
 FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}

// *** REPLACE FROM HERE ***
void loop() {
 colorWipe(0x00,0xff,0x00, 50);
 colorWipe(0x00,0x00,0x00, 50);
}

void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
 for(uint16_t i=0; i<NUM_LEDS; i++) {
     setPixel(i, red, green, blue);
     showStrip();
     delay(SpeedDelay);
 }
}
// *** REPLACE TO HERE ***

void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H 
  // NeoPixel
  strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
  // FastLED
  FastLED.show();
#endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H 
  // NeoPixel
  strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H 
  // FastLED
  leds[Pixel].r = red;
  leds[Pixel].g = green;
  leds[Pixel].b = blue;
#endif
}

void setAll(byte red, byte green, byte blue) {
 for(int i = 0; i < NUM_LEDS; i++ ) {
   setPixel(i, red, green, blue); 
 }
 showStrip();
}

Please show code using code tags </>.

Please study the example code, coming with every library. It’s not clear to me what effect you want to achieve.

Color Wipe

Like in the video, where it wipes across the whole strip - instead I would like it to start in the center and wipe outward toward the left and right edges simultaneously.

I had created a different thread as I'm using adafruit neopixel library, I managed to accomplish the color wipe from middle out (like a traffic adviser on a car)

I havent used the fast library so i have no idea how to change mine to work.

arduino forum link

Hey, thanks!! I'll check it out! :-D

I didn't have much luck with it. For some reason or another it won't compile. I guess I could be a little lost with all the subs in there.

What parts of that code do I need to make it work properly?

I figured it out. The following code works.

#include <Adafruit_NeoPixel.h>


#define RINGPIN 5


uint8_t NUMPIXELS = 16;      // total number of LED's in the ring display

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, RINGPIN, NEO_RGB + NEO_KHZ800);  // an instance for the LED ring display

void setup() {
  // put your setup code here, to run once:
  strip.begin();
  Serial.begin(9600);
}



void loop() {

  //Ascend strip
  for (int i = NUMPIXELS / 2; i >= 0; i--) {
    //for (int i = 0; i < (NUMPIXELS / 2) + 1; i++) { 
    strip.setPixelColor(i, strip.Color(0, 64, 0));
    strip.setPixelColor(NUMPIXELS - i, strip.Color(0, 64, 0));
    strip.show();
    delay(35);
  }

  // Descend Strip
  for (int i = NUMPIXELS / 2 ; i >= 0; i--) {
    //for (int i = 0; i < (NUMPIXELS / 2) + 1; i++) { 
    strip.setPixelColor(i, strip.Color(0, 0, 0));
    strip.setPixelColor(NUMPIXELS - i, strip.Color(0, 0, 0));
    strip.show();
    delay(50);
  }

}

Fair enough.

In case you should still want it I’ve rearranged my code to work on yours, the only thing that you would have to change is in the main loop colorWipeDual allows you to change the delay and the 2 outward colors, then it will flash over the whole thing white and repeat

code should work outright as I change the variables to match you pixel ring

#include <Adafruit_NeoPixel.h>

#define PIN 5


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


void setup() {

  strip.begin();
  colorWipe(strip.Color(5, 5, 5), 0); // dim white no chase
  strip.show(); // Initialize all pixels to 'off'

}

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

//loop goes forward, starts halfway
void colorWipe2(uint32_t c, uint8_t wait) {
  for(uint16_t i=9; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

//error with this loop 

void colorWipeDual(uint32_t c, uint8_t wait, uint32_t b)
{
uint16_t j = 1;
uint16_t HALFWAY = 8;

    for (uint16_t i = HALFWAY; i < strip.numPixels(); i++) 
    {
        strip.setPixelColor(HALFWAY - j, b);    //scans to the right (color currently set to red)
        strip.setPixelColor(i, c);              //scans to the left (color currently set to blue)
        j++;
        strip.show();
        delay(wait);
          if (j==10){
          j = 1;
          }
    }
}

//loop goes in reverse working, starts halfway
void colorWipeREV(uint32_t c, uint8_t wait) {
  for(int16_t i=8; i>-1; i--) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}



void loop() {


 colorWipeDual (strip.Color(150, 0, 0), 50, strip.Color(0, 0, 150)); // RGB left , delay, RGB right
 delay (200);
 colorWipe(strip.Color(5, 5, 5), 0); // dim white no chase
 strip.show(); // Initialize all pixels to 'off'
 delay (200);

   
  }

#include “FastLED.h”
#define NUM_LEDS 50
CRGB leds[NUM_LEDS];
#define PIN 6

void setup()
{
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}

// *** REPLACE FROM HERE ***
void loop() {
colorWipe(0x00,0xff,0x00, 50);
colorWipe(0x00,0x00,0xff, 50);
colorWipe(0xff,0x00,0x00, 50);
colorWipe(0x0f,0xff,0x0f, 50);
colorWipe(0,255,50, 50);
colorWipe(0xff,0x24,0xf8, 50);
colorWipe(0xe9,0xff,0x21, 50);
colorWipe(0,255,20, 50);
colorWipe(0x1f,0x0f,0xff, 50);
colorWipe(0x12,0xff,0x88, 50);
colorWipe(0xff,0xff,0xff, 50);
}

void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
for(int i = 0; i < (NUM_LEDS / 2) + 1; i++) {
setPixel(i, red, green, blue);
setPixel(NUM_LEDS - i, red, green, blue);
showStrip();
delay(SpeedDelay);
}
}
// *** REPLACE TO HERE ***

void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}

void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Tom… :slight_smile: