Loop problems - nested loops

Hey everyone I am struggling hard over here, I modified some code, and wrote some of my own to create a light display. This display is supposed to cycle between the C9 christmas light colors, then move to a blue and white with glitter pattern, then move to a red white and green pattern, the red white and green are supposed to move from one end to the other. The patterns all work as expected separately, but when i combined them into a large loop the patterns turn on and go black, then come back on, then it moves to pattern blue and white with glitter works as expected. then it moves to the red white and green which goes to the right color but does not move as expected. Any help or pointers are greatly appreciated

here is a video of what happens. I also attached all of the code, the top file is the master list of patterns together - not working as expected.

I added the code for all of the separate patterns which are working as expected

**Video of xmas.imo file in action – NOT WORKING AS EXPECTED ****

Video of red white green moving

Video of the blue white with glitter

Video of C9 Colors cycling

Xmas.ino (42.8 KB)

Blue_White.ino (8.09 KB)

Xmas_lights_2811.ino (29.1 KB)

Red_Green_White_2811.ino (5.9 KB)

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.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :)

kbostick88: I also attached all of the code, the top file is the master list of patterns together

I don't know about other people but I am much too lazy to wade through 42k of code. Can't you make a small demo program that illustrates your problem?

...R

  EVERY_N_MILLISECONDS( 20 ) {
    gHue++;
  }

This variable never gets used anywhere.

  FastLED.show();
  addGlitter(9100);

I'm not sure but this doesn't look like it displays the glitter. I would expect these two lines to be reversed. But since the main loop is now responsible for the .show() method, it should not be here at all.

And I think that's the problem with the nested-loop RGW() function. It runs through its whole cycle without ever calling .show(). Change it so that it doesn't use the loops. It should advance its internal variable c by 1 each time it's called AND 200ms has passed since the last call. Make c a static so its value is stored between each call to RGW(). I'm not really sure what it's doing with i. Maybe that advances every 200ms? I didn't open the "source" sketch.

Here is a diagram of the circuit

kbostick88: then it moves to the red white and green which goes to the right color but does not move as expected.

How can we know what you expect?

I posted a video of the expected output, that is working properly, but when i merge the files together the last output is not working as expected. The Red White and Green should cycle through and you should be able to see the dots move down the path of LEDs

Sorry, I got my quote tags out of order in my post #3. I have fixed it. My solution should now be readable.

I removed the code that was never called with ghue, but am unsure what you mean about the show commands

Hi,
OPs circuit.

I hope its really connected like this;

Tom.. :slight_smile:

Hi, Did you google ws2811 arduino pattern programming

http://yaab-arduino.blogspot.com.au/p/ala.html

https://plus.google.com/u/0/communities/109127054924227823508

also the FastLed examples in the IDE?

Tom... :)

kbostick88: I removed the code that was never called with ghue, but am unsure what you mean about the show commands

All of the fancy manipulation of colours is done on an array inside the Arduino's memory. It is only sent out to the LEDs to show that pattern when you call the .show() method.