0

Reversing Strip
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Reversing Strip

by wiremonkey on Thu Dec 12, 2019 7:17 pm

Hello,

I have searched a bit but cannot seem to find an answer to this problem. I have a strip 60 count strip of neopixels and am using a potentiometer to fill in the strip. The program is working great but because of the way I have to configure the LEDs I need to reverse the order the strip gets filled. Instead of starting to fill from the DI side I want it to fill from the DO side on the other side of the strip.

Is that possible to do with the code I have?

Code: Select all | TOGGLE FULL SIZE
  //Turn on correct number of LEDs based on numOn
  for (int i = 0; i < 60; i++) {
   
    if (i < numOn+1) { //the +1 keeps one LED on at all times
      strip_1.setPixelColor(i, 0, 25, 255);  // turn on this LED, also adjusts colors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  ); //turn on this LED, adjust values to affect colors and brightness of LEDs
     
    }
    else {
      strip_1.setPixelColor(i, 0, 0, 0); //turn off this LED
     
    }
  }

  strip_1.show(); //Apply changes to Strip


I've tried to replace this
Code: Select all | TOGGLE FULL SIZE
for (int i = 0; i < 60; i++) 

With this
Code: Select all | TOGGLE FULL SIZE
for (int i = 60; i > 0; i--) 


but that didn't seem to work.

Thank you for any help.

wiremonkey
 
Posts: 17
Joined: Fri Oct 31, 2014 1:02 am

Re: Reversing Strip

by adafruit_support_bill on Thu Dec 12, 2019 7:46 pm

Try changing this line:
Code: Select all | TOGGLE FULL SIZE
if (i < numOn+1)


to:
Code: Select all | TOGGLE FULL SIZE
if (i > (60 - numOn))

adafruit_support_bill
 
Posts: 76160
Joined: Sat Feb 07, 2009 10:11 am

Re: Reversing Strip

by wiremonkey on Thu Dec 12, 2019 8:04 pm

YES! That did it. Thank you very much!

wiremonkey
 
Posts: 17
Joined: Fri Oct 31, 2014 1:02 am

Re: Reversing Strip

by adafruit_support_bill on Thu Dec 12, 2019 8:05 pm

Great! Happy hacking.

adafruit_support_bill
 
Posts: 76160
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.