Neopixel Loop & fade simple test code

I am using the simple test code with 2 adafruit neopixel sticks connected.
I would just like to loop the code so that once ALL the leds are turned on, they then turn off one by one, in the same continuous loop (to repeat over & over).
Ideally I would like them them to fade on/off slightly as well for a smoother change.
I know this is really simple but I just can’t get it today! Everything I try turns them on & off straight away rather than staying on for the full cycle.

code below…

thanks in advance

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
void setup() {
  pixels.begin(); // This initializes the NeoPixel library.
void loop() {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  for(int i=0;i<NUMPIXELS;i++){
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.; // This sends the updated pixel color to the hardware.
    delay(delayval); // Delay for a period of time (in milliseconds).

I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy

1 Like

Hmm, it seems like your use case is close to the color wipe example:

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

I would maybe try starting from that example, and then working back to your use case? You can find that example under the neopixel library, under “extra-examples.cpp”.

I hope that helps! :slight_smile: