0

Help combining 2 Dotstar LED loops
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help combining 2 Dotstar LED loops

by ldodge417 on Tue Jun 01, 2021 8:40 pm

I'm trying to combine 2 light effects on a 16 LED strip and I haven't got it right yet. I don't fully understand the different for loops. I've tried several different combinations that have made some neat effects, but not what I'm trying to make.

This first one is the theater lights from the demo:

Code: Select all | TOGGLE FULL SIZE
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<1; j++) {  //do 1 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }     
    if (Breakloop)
      {Breakloop=false;j=1;q=3;}

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}


The second one is a rainbow cycle:

Code: Select all | TOGGLE FULL SIZE
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*1; j++) { // 1 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }

    if (Breakloop)
    {Breakloop=false;j=256;}   
  }
}


So I'm trying to combine these for a "rainbow cycle theater-chase". Both of these loops are working independently.

Any suggestions on what I can try?

Thanks!

ldodge417
 
Posts: 8
Joined: Sat Aug 22, 2015 12:19 pm

Re: Help combining 2 Dotstar LED loops

by adafruit_support_bill on Wed Jun 02, 2021 6:35 am

So I'm trying to combine these for a "rainbow cycle theater-chase".

What exactly would that look like? 90% of software engineering is coming up with a precise definition of the requirements.
If you can describe in detail when and how the colors change, you will be a lot closer to understanding how to code it.

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

Please be positive and constructive with your questions and comments.


cron