Newbie Question - Neopixel Direction

New to Arduino and neopixels. I have been using the example sketches in the adafruit.neopixel library and reading online to learn, but this is stumping me and its probably something easy.

All I want to do is reverse the direction of the "simple" neopixel example that lights them from 0 to the end of the strip. I took this :

// The first NeoPixel in a strand is #0, second is 1, all the way up
// to the count of pixels minus one.
for(int i=0; i<NUMPIXELS; i++) { // For each pixel...

// pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
// Here we're using a moderately bright green color:
pixels.setPixelColor(i, pixels.Color(0, 150, 0));

pixels.show();   // Send the updated pixel colors to the hardware.

delay(DELAYVAL); // Pause before next pass through loop

and changed it to what made sense to me:

for(int i = NUMPIXELS-1 ; i >= 0; i--) { // For each pixel...

but it is not working. Can someone explain/teach a newbie how to fish?

Thank you!

for(int i = NUMPIXELS - 1; i >=0;i = i-1)

1 Like

That should work, you did something else (or didn’t do)

That'll do it. THANKS!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.