<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Question - Modified version of the FLORA Umbrella project - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/question-modified-version-of-the-flora-umbrella-project/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Mon, 20 Apr 2026 12:49:44 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Question - Modified version of the FLORA Umbrella project</title>
                        <link>https://www.tweaking4all.com/forum/arduino/question-modified-version-of-the-flora-umbrella-project/#post-4283</link>
                        <pubDate>Tue, 12 Jul 2022 08:36:06 +0000</pubDate>
                        <description><![CDATA[Hi Jack,
sorry that I had to move the code here - as mentioned in the form, we&#039;d prefer folks to not post long code examples in the comments, since it takes up so much space.No harm done th...]]></description>
                        <content:encoded><![CDATA[<p>Hi Jack,</p>
<p>sorry that I had to move the code here - as mentioned in the form, we'd prefer folks to not post long code examples in the comments, since it takes up so much space.<br />No harm done though - all good ... </p>
<p>So coming to your problem: </p>
<p>Each of the effects you had before can run one step at a time, each time an effect is called. <br />So the effect is accomplished by running through the loop in "loop()" (the switch section).</p>
<p>The theatre effect however, runs the entire effect and only returns from the effect back to the "loop()" after the effect has been completed.<br />Therefor making it impossible to read the button push.</p>
<p>More details on this can be found in the follow-up article I had written: <a href="https://www.tweaking4all.com/hardware/arduino/arduino-all-ledstrip-effects-in-one/" target="_blank" rel="noopener">Arduino – All LEDStrip effects in one (NeoPixel and FastLED)</a><br />Here I've described the challenges you're looking at right now 🙂 </p>
<p>If the code there doesn't do the trick (looks like you already are using the code from there), then you could add a "break" in the  effect loop.<br />I haven't used the <a href="https://github.com/mathertel/OneButton" target="_blank" rel="noopener">OneButton</a> library (looks quite useful though!), so I do not really know how that is done.</p>
<p>Example:</p>
<pre contenteditable="false">void theaterChaseRainbow(int SpeedDelay) {
  byte *c;
  for (int j=0; j&lt;256; j++) {
    for (int q=0; q&lt;3; q++) {
      for (int i=2; i&lt;NUM_LEDS-2; i=i+3) {
        c = Wheel(j);
        setPixel(i+q, *c, *(c+1), *(c+2));
      }
      showStrip();

      // ---&gt;&gt;&gt;&gt; HERE: return if button was pressed
      // something like this pseudo code: 
      // if(button pressed) { return; }

      delay(SpeedDelay);
    }
  }
}</pre>
<p> </p>
<p> it could be that you'd need to call "<strong>btn.tick();</strong>" there and/or see if <strong>patternCounter</strong> is still "<strong>6</strong>" (eg. has not yet changed).</p>
<p>For readability I'd also change the "nextPattern" function to something like this (not many people work work with modulo calculations in this fashion ... as far as I know):</p>
<pre contenteditable="false">void nextPattern() {
   if(patternCounter&lt;7)  { 
      patternCounter++;   // increase by 1 if not yet at last effect
    } else  {
       patternCounter=0;  // go back to first effect if going beyond last effect
    }
}
</pre>
<p> </p>
<p> Not sure if all this will resolve the issue, but it should get you started 😊 </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/question-modified-version-of-the-flora-umbrella-project/#post-4283</guid>
                    </item>
				                    <item>
                        <title>Question - Modified version of the FLORA Umbrella project</title>
                        <link>https://www.tweaking4all.com/forum/arduino/question-modified-version-of-the-flora-umbrella-project/#post-4282</link>
                        <pubDate>Tue, 12 Jul 2022 07:37:35 +0000</pubDate>
                        <description><![CDATA[Hey there
this is the second time I’ve been trying to write this message, the previous one was marked as spam so I apologize if I’m a little brief.
I’d like to begin just by thanking you f...]]></description>
                        <content:encoded><![CDATA[<p>Hey there</p>
<p>this is the second time I’ve been trying to write this message, the previous one was marked as spam so I apologize if I’m a little brief.</p>
<p>I’d like to begin just by thanking you for all this work that you put into these effects I really appreciate it and it has been very helpful in helping me learn to code using the fast LED library.</p>
<p> </p>
<p>I am currently working on a modified version of the FLORA Umbrella project.</p>
<p>essentially it is using the flora controller, the fast LED library, and the one button library. I am trying to create a sketch that can toggle through various effects using auxiliary button. I have been successful in using your code to create other projects, in successful in this project with adding other effects. However when attempting to add the theater chase rainbow effect to the pattern toggling sketch I encounter several problems. First it often takes several coggles to reach the theater effect, meaning that I have to cycle through all the other effects multiple times before I see the theater effect. Once I do reach the theater effect it will no longer allow me to toggle through effects. Another problem I have encountered is that sometimes it won’t even reach the theater chase effect it will actually just freeze end require a restart to continue usage. Not sure where I’m going wrong in the code I’ve tried to trim it down and figure out what it is the essentials but can’t seem to figure out what is stopping this from working and also causing this to freeze.</p>
<p> </p>
<p>Here is my code,</p>
<pre contenteditable="false">#include &lt;OneButton.h&gt;<br />#include &lt;FastLED.h&gt;<br /><br />#define NUM_LEDS  240<br />#define LED_PIN   6<br />#define BTN_PIN   10  <br />#define NUM_COLORS 5<br />static const CRGB TwinkleColors  = <br />{<br />    CRGB::Red,<br />    CRGB::Blue,<br />    CRGB::Purple,<br />    CRGB::Green,<br />    CRGB::Yellow<br />};     <br />CRGB leds;<br />uint8_t patternCounter = 0;<br />uint8_t gHue = 0; // rotating "base color" used by many of the patterns<br />  <br />// Push button connected between pin 7 and GND (no resistor required)<br />OneButton btn = OneButton(BTN_PIN, true, true);<br />void setup() {<br />  FastLED.addLeds&lt;WS2812, LED_PIN, GRB&gt;(leds, NUM_LEDS);<br />  FastLED.setBrightness(50);<br />  Serial.begin(57600);<br />   FastLED.clear(true);<br />  btn.attachClick(nextPattern);<br />}<br />void loop() {<br />  <br />  switch (patternCounter) {<br />    case 0:<br />      movingDots();<br />      break;<br />    case 1:<br />      rainbowBeat();<br />      break;<br />    case 2:<br />      redWhiteBlue();<br />      break;<br />    case 3:<br />      DrawComet();<br />      break;<br />    case 4:<br />      juggle();<br />      break;<br />    case 5:<br />      bpm();<br />      break; <br />    case 6:<br />      theaterChaseRainbow(50);<br />      break;<br />  }<br />  <br />  FastLED.show();<br />  btn.tick();<br />}<br />void nextPattern() {<br />  patternCounter = (patternCounter + 1) % 7;           // Change the number after the % to the number of patterns you have<br />}<br /><br />void movingDots() {<br />  <br />  uint16_t posBeat  = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);<br />  uint16_t posBeat2 = beatsin16(60, 0, NUM_LEDS - 1, 0, 0);<br />  uint16_t posBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 32767);<br />  uint16_t posBeat4 = beatsin16(60, 0, NUM_LEDS - 1, 0, 32767);<br />  // Wave for LED color<br />  uint8_t colBeat  = beatsin8(45, 0, 255, 0, 0);<br />  leds  = CHSV(colBeat, 255, 255);<br />  leds  = CHSV(colBeat, 255, 255);<br />  fadeToBlackBy(leds, NUM_LEDS, 10);<br />}<br /><br />void rainbowBeat() {<br />  <br />  uint16_t beatA = beatsin16(30, 0, 255);<br />  uint16_t beatB = beatsin16(20, 0, 255);<br />  fill_rainbow(leds, NUM_LEDS, (beatA+beatB)/2, 8);<br />}<br /><br />void redWhiteBlue() {<br />  uint16_t sinBeat   = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);<br />  uint16_t sinBeat2  = beatsin16(30, 0, NUM_LEDS - 1, 0, 21845);<br />  uint16_t sinBeat3  = beatsin16(30, 0, NUM_LEDS - 1, 0, 43690);<br />  leds   = CRGB::Pink;<br />  leds  = CRGB::Aqua;<br />  leds  = CRGB::Green;<br />  <br />  fadeToBlackBy(leds, NUM_LEDS, 10);<br />}<br />void DrawComet()<br />{<br />    const byte fadeAmt = 28;<br />    const int cometSize = 80;<br />    const int deltaHue  = 4;<br />    static byte hue = HUE_RED;<br />    static int iDirection = 1;<br />    static int iPos = 0;<br />    hue += deltaHue;<br />    iPos += iDirection;<br />    if (iPos == (NUM_LEDS - cometSize) || iPos == 0)<br />        iDirection *= -1;<br />    <br />    for (int i = 0; i &lt; cometSize; i++)<br />        leds.setHue(hue);<br />    <br />    // Randomly fade the LEDs<br />    for (int j = 0; j &lt; NUM_LEDS; j++)<br />        if (random(10) &gt; 5)<br />            leds = leds.fadeToBlackBy(fadeAmt);<br />    delay(10);<br />}<br />void juggle() {<br />  // eight colored dots, weaving in and out of sync with each other<br />  fadeToBlackBy( leds, NUM_LEDS, 20);<br />  byte dothue = 0;<br />  for( int i = 0; i &lt; 8; i++) {<br />    leds |= CHSV(dothue, 200, 255);<br />    dothue += 32;<br />  }<br />}<br />void bpm()<br />{<br />  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)<br />  uint8_t BeatsPerMinute = 100;<br />  CRGBPalette16 palette = PartyColors_p;<br />  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);<br />  for( int i = 0; i &lt; NUM_LEDS; i++) { //9948<br />    leds = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));<br />  }<br />}<br />void theaterChaseRainbow(int SpeedDelay) {<br />  byte *c;<br />  for (int j=0; j&lt;256; j++) {<br />    for (int q=0; q&lt;3; q++) {<br />      for (int i=2; i&lt;NUM_LEDS-2; i=i+3) {<br />        c = Wheel(j);<br />        setPixel(i+q, *c, *(c+1), *(c+2));<br />      }<br />      showStrip();<br />      delay(SpeedDelay);<br />    }<br />  }<br />}<br />byte * Wheel(byte WheelPos) {<br />  static byte c;<br /> <br />  if(WheelPos &lt; 85) {<br />   c=WheelPos * 3;<br />   c=255 - WheelPos * 3;<br />   c=0;<br />  } else if(WheelPos &lt; 170) {<br />   WheelPos -= 85;<br />   c=255 - WheelPos * 3;<br />   c=0;<br />   c=WheelPos * 3;<br />  } else {<br />   WheelPos -= 170;<br />   c=0;<br />   c=WheelPos * 3;<br />   c=255 - WheelPos * 3;<br />  }<br />  return c;<br />}<br />void showStrip() {<br />   FastLED.show();<br />}<br />void setPixel(int Pixel, byte red, byte green, byte blue) {<br />   leds.r = red;<br />   leds.g = green;<br />   leds.b = blue;<br />}</pre>
<p> </p>
<p>Thank you in advanced for any help!</p>
<p>p.s Trying to finish this for an even next week so hoping to get this fixed by then &lt;3 I’ll def post photos/vids when I finish it!</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/question-modified-version-of-the-flora-umbrella-project/#post-4282</guid>
                    </item>
							        </channel>
        </rss>
		