<?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>
									LED Effects - Candy Cane - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 21 Jul 2026 00:43:13 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4732</link>
                        <pubDate>Wed, 22 Feb 2023 07:38:41 +0000</pubDate>
                        <description><![CDATA[Hello!
The code for the fire is here somewhere on the forum, adapted to the fire code part. 
For the fire, it also works very well. 
I can either set a time when calling (FireTime) 
case...]]></description>
                        <content:encoded><![CDATA[<p>Hello!</p>
<p><span class="HwtZe"><span class="jCAhz ChMk0b"><span class="ryNqvb">The code for the fire is here somewhere on the forum, adapted to the fire code part.</span></span> </span></p>
<p><span class="HwtZe"><span class="jCAhz ChMk0b"><span class="ryNqvb">For the fire, it also works very well.</span></span> </span></p>
<p><span class="HwtZe"><span class="jCAhz ChMk0b"><span class="ryNqvb">I can either set a time when calling (FireTime) </span></span></span></p>
<pre contenteditable="false">case 17 : {
// Fire - Cooling rate, Sparking rate, speed delay, int Seconds
FireTime(85,120,100,30);  //call the effect FIRE for 30sec 
break;
}</pre>
<p><span class="HwtZe"><span class="jCAhz ChMk0b"><span class="ryNqvb">or just call (Fire) directly without a set time.</span></span></span></p>
<pre contenteditable="false">case 23 : {
// LongBurn Fire - Cooling rate, Sparking rate, speed delay
Fire(85,120,100);  // call the FIRE effect endless without time
break;
}</pre>
<p><span class="HwtZe"><span class="jCAhz ChMk0b"><span class="ryNqvb">The code is therefore only an addition to the actual effect code.</span></span> <span class="jCAhz ChMk0b"><span class="ryNqvb">It works with the fire, but unfortunately not with the candy here.</span></span></span></p>
<p>... no problem</p>
<p>i give up with this candy ^^</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Anonymous</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4732</guid>
                    </item>
				                    <item>
                        <title>RE: LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4730</link>
                        <pubDate>Tue, 21 Feb 2023 09:56:10 +0000</pubDate>
                        <description><![CDATA[Not sure where you got the Fire code, but maybe look at my All-in-One LED Effects article?
The general idea is that an effect is broken is small steps that get executed until the variable &quot;...]]></description>
                        <content:encoded><![CDATA[<p>Not sure where you got the Fire code, but maybe look at <a href="https://www.tweaking4all.com/hardware/arduino/arduino-all-ledstrip-effects-in-one/" target="_blank" rel="noopener">my All-in-One LED Effects article</a>?</p>
<p>The general idea is that an effect is broken is small steps that get executed until the variable "selectedEffect" changes.<br />This meant for the Fire effect that I had to break it in pieces as well (I hope I remembered that right).<br />See <a href="https://www.tweaking4all.com/hardware/arduino/arduino-all-ledstrip-effects-in-one/#ChallengesExplained" target="_blank" rel="noopener">the explanation I wrote on "endless" effects</a>.</p>
<p>😊 </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/led-effects-candy-cane/#post-4730</guid>
                    </item>
				                    <item>
                        <title>RE: LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4729</link>
                        <pubDate>Mon, 20 Feb 2023 19:48:46 +0000</pubDate>
                        <description><![CDATA[in my big sketch are 3 parts for every effect.
String CandyCaneMessage = &quot;CandyCane&quot;; //endless
void ShowEffect(int selectedEffect) {

switch(selectedEffect) {

case 22 : {
//(Color1,...]]></description>
                        <content:encoded><![CDATA[<p>in my big sketch are 3 parts for every effect.</p>
<p><strong>String CandyCaneMessage = "CandyCane"; //endless</strong></p>
<pre contenteditable="false">void ShowEffect(int selectedEffect) {

switch(selectedEffect) {

case 22 : {
//(Color1,Color2,Color3,BlockWidth,WaveDelay,Instant)
//CandyCane(CRGB::Blue, CRGB::Green, CRGB::Red, 6, 100, false);
CandyCane(CRGB(0xff,0,0xff), CRGB(0,0xff,0), CRGB(0,0,0xff), 9, 100, false);
break;
}</pre>
<p>the function</p>
<pre contenteditable="false">void CandyCane(CRGB Color1, CRGB Color2, CRGB Color3, int BlockWidth, int WaveDelay, bool Instant) {
#define NumberOfColors 3
int BlockLEDCounter;
int ColorCounter;
int LedPosition;

if(Instant) {
// Fill initial pattern
for(int i=0; i &lt; NUM_LEDS; i=i + (NumberOfColors*BlockWidth) )
{
for (ColorCounter=0; ColorCounter &lt; NumberOfColors; ColorCounter++)
{
for(BlockLEDCounter=0; BlockLEDCounter &lt; BlockWidth; BlockLEDCounter++)
{
LedPosition = i + (ColorCounter*BlockWidth) + BlockLEDCounter;

if( LedPosition &lt; NUM_LEDS) {
switch (ColorCounter)
{
case 0: leds = Color1; break;
case 1: leds = Color2; break;
case 2: leds = Color3; break;
}
}
}
}
}
}

else
{
// Black for all LEDs
fill_solid(leds,NUM_LEDS,CRGB::Black);
}

FastLED.show();

// Scrolling bars
BlockLEDCounter = 0;
ColorCounter = 0;

while(true)
{
for(int i=0; i&lt;10; i++) //Need to make 10 times
{
memmove( &amp;leds, &amp;leds, (NUM_LEDS-1) * sizeof(CRGB) );

switch (ColorCounter)
{
case 0: leds = Color3; break;
case 1: leds = Color2; break;
case 2: leds = Color1; break;
}

FastLED.show();

BlockLEDCounter++;

if (BlockLEDCounter==BlockWidth)
{
BlockLEDCounter = 0;
ColorCounter++;
if (ColorCounter==NumberOfColors) {
ColorCounter = 0;
}
}

delay(WaveDelay);
}
}
}</pre>
<p>and the call</p>
<pre contenteditable="false">else if(ircMessage.text == CandyCaneMessage) // endless
{
sendTwitchMessage(ircMessage.nick + " switching " + ircMessage.text);
ShowEffect(22);
}</pre>
<p>i´ve tried to make this like the "fire" effect, but it hasn´t worked...</p>
<pre contenteditable="false">void FireTime(int Cooling, int Sparking, int SpeedDelay, int Seconds) {
unsigned long startTime = millis();
unsigned long runMillis = 1000 * Seconds;

while (millis() - startTime &lt; runMillis) {
Fire(Cooling, Sparking, SpeedDelay);
}
fill_solid( leds, NUM_LEDS, CRGB(0,0,0)); // Hintergrundfarbe?
}</pre>
<p> </p>
<p> </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Anonymous</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4729</guid>
                    </item>
				                    <item>
                        <title>RE: LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4726</link>
                        <pubDate>Sun, 19 Feb 2023 10:56:39 +0000</pubDate>
                        <description><![CDATA[That&#039;s odd. Can you post the CandyCane function code?]]></description>
                        <content:encoded><![CDATA[<p>That's odd. Can you post the CandyCane function code?</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/led-effects-candy-cane/#post-4726</guid>
                    </item>
				                    <item>
                        <title>RE: LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4723</link>
                        <pubDate>Sat, 18 Feb 2023 17:24:43 +0000</pubDate>
                        <description><![CDATA[good idea.
lights on, but no movement....]]></description>
                        <content:encoded><![CDATA[<p>good idea.</p>
<p>lights on, but no movement....</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Anonymous</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4723</guid>
                    </item>
				                    <item>
                        <title>RE: LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4717</link>
                        <pubDate>Sat, 18 Feb 2023 09:34:00 +0000</pubDate>
                        <description><![CDATA[What you could try is recording the current time at just before the &quot;while(true)&quot; loop, and in the loop keep comparing &quot;now&quot; with that recorded time. If the difference becomes &gt;30 then ex...]]></description>
                        <content:encoded><![CDATA[<p>What you could try is recording the current time at just before the "while(true)" loop, and in the loop keep comparing "now" with that recorded time. If the difference becomes &gt;30 then exit the loop.</p>
<p>I have not tested this, so you'll have to give it a try. It replaces the while-loop in the effect function (starts with "while(true)").</p>
<pre contenteditable="false">  unsigned long startTime = millis();

  while( ((millis() - startTime) * 1000) &lt;30) 
  {
    memmove( &amp;leds, &amp;leds, (NUM_LEDS-1) * sizeof(CRGB) );

    switch (ColorCounter) 
    {
      case 0: leds = Color3; break;
      case 1: leds = Color2; break;
      case 2: leds = Color1; break;
    }

    FastLED.show();
    
    BlockLEDCounter++;
    
    if (BlockLEDCounter==BlockWidth) 
    {
      BlockLEDCounter = 0;
      ColorCounter++;
      if (ColorCounter==NumberOfColors) {
        ColorCounter = 0;
      }
    }
    
    delay(WaveDelay);
  }</pre>
<p>Hope this helps! 😊 </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/led-effects-candy-cane/#post-4717</guid>
                    </item>
				                    <item>
                        <title>RE: LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4715</link>
                        <pubDate>Sat, 18 Feb 2023 04:08:53 +0000</pubDate>
                        <description><![CDATA[thanks for sharing!
i like it, but please allow the question:
How to let this run only for 30sec. or 10 rounds, then stop?]]></description>
                        <content:encoded><![CDATA[<p>thanks for sharing!</p>
<p>i like it, but please allow the question:</p>
<p>How to let this run only for 30sec. or 10 rounds, then stop?</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Anonymous</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-4715</guid>
                    </item>
				                    <item>
                        <title>LED Effects - Candy Cane</title>
                        <link>https://www.tweaking4all.com/forum/arduino/led-effects-candy-cane/#post-2982</link>
                        <pubDate>Mon, 04 Jan 2021 16:19:33 +0000</pubDate>
                        <description><![CDATA[Based on a request by James, here two examples of a Candy Cane effect.Both effects use shifting of LED positions (move each LED color over one position and add a new one at the beginning of ...]]></description>
                        <content:encoded><![CDATA[<p>Based on a <a href="https://www.tweaking4all.com/hardware/arduino/arduino-all-ledstrip-effects-in-one/#comment-528833" target="true">request by James</a>, here two examples of a Candy Cane effect.<br />Both effects use shifting of LED positions (move each LED color over one position and add a new one at the beginning of the strand).</p>
<p>The first one is the simplest, but you'll have to make sure the the block width * 3 divides nicely with your LED count.<br />The reason for this is that the last LED will be used to color the first new LED.<br />So for example with 60 LEDs, we'd like to make 3 blocks of 10, or 3 blocks of 20, which makes it that the last LED indeed is the correct color for the new first LED.</p>
<p>With both you can define your own colors (3), block width, and speed (WaveDelay higher = slower scrolling).</p>
<p>The colors can be <a href="https://github.com/FastLED/FastLED/wiki/Pixel-reference#user-content-predefined-colors-list" target="true">predefined FastLED colors</a>, for example <span style="color: #0000ff"><strong>CRGB::Black</strong></span>, or a user defined color, for example <span style="color: #0000ff">CRGB(0,0,0)</span>.</p>
<pre>#include "FastLED.h"
#define NUM_LEDS 60
CRGB leds;
#define PIN 6
<br />#define NumberOfColors 3<br />
void setup()
{
  FastLED.addLeds&lt; WS2811, PIN, GRB &gt;(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}

void loop() {
  CandyCaneSimple(CRGB::Red, CRGB::White, CRGB::Blue, 10, 100); 
}

void CandyCaneSimple(CRGB Color1, CRGB Color2, CRGB Color3, int BlockWidth, int WaveDelay) {
  int LedPosition;
  CRGB lastLedColor;
  
  if(Instant) {
    // Fill initial pattern
    for(int i=0; i &lt; NUM_LEDS; i=i + (NumberOfColors*BlockWidth) ) 
    {
      for (int ColorCounter=0; ColorCounter &lt; NumberOfColors; ColorCounter++) 
      {
        for(int BlockLEDCounter=0; BlockLEDCounter &lt; BlockWidth; BlockLEDCounter++) 
        {
          LedPosition = i + (ColorCounter*BlockWidth) + BlockLEDCounter;
          
          if( LedPosition &lt; NUM_LEDS) {
            switch (ColorCounter) 
            {
              case 0: leds = Color1; break;
              case 1: leds = Color2; break;
              case 2: leds = Color3; break;
            }
          }
        }
      }
    }
  }
  else
  {
    // Black for all LEDs
    fill_solid(leds,NUM_LEDS,CRGB::Black);
  }

  FastLED.show();
  delay(5000);
  // Scrolling bars
  
  while(true) 
  {
    lastLedColor = leds;
    memmove( &amp;leds, &amp;leds, (NUM_LEDS-1) * sizeof(CRGB) );
    leds = lastLedColor;
    FastLED.show();
    delay(WaveDelay);
  }
}
</pre>
<p> </p>
<p>The second one allows for a little more flexibility, since it will determine what the new first LED should be, and it allows for a slow start (Instant = false) where the color bar slowly build up.<br />If instant = true then the entire strand is first filled with blocks and after that is starts scrolling.</p>
<pre>#include "FastLED.h"
#define NUM_LEDS 60
CRGB leds;
#define PIN 6

void setup()
{
  FastLED.addLeds &lt; WS2811, PIN, GRB&gt;(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}

void loop() {
  //CandyCane(CRGB::Blue, CRGB::White, CRGB::Red, 6, 100, false);
  CandyCane(CRGB::Blue, CRGB::White, CRGB::Red, 8, 100, true); 
}

void CandyCane(CRGB Color1, CRGB Color2, CRGB Color3, int BlockWidth, int WaveDelay, bool Instant) {
  #define NumberOfColors 3
  int BlockLEDCounter;
  int ColorCounter;
  int LedPosition;
  
  if(Instant) {
    // Fill initial pattern
    for(int i=0; i &lt; NUM_LEDS; i=i + (NumberOfColors*BlockWidth) ) 
    {
      for (ColorCounter=0; ColorCounter &lt; NumberOfColors; ColorCounter++) 
      {
        for(BlockLEDCounter=0; BlockLEDCounter &lt; BlockWidth; BlockLEDCounter++) 
        {
          LedPosition = i + (ColorCounter*BlockWidth) + BlockLEDCounter;
          
          if( LedPosition  &lt;  NUM_LEDS) {
            switch (ColorCounter) 
            {
              case 0: leds = Color1; break;
              case 1: leds = Color2; break;
              case 2: leds = Color3; break;
            }
          }
        }
      }
    }
  }
  else
  {
    // Black for all LEDs
    fill_solid(leds,NUM_LEDS,CRGB::Black);
  }

  FastLED.show();
  
  // Scrolling bars
  BlockLEDCounter = 0;
  ColorCounter = 0;
  
  while(true) 
  {
    memmove( &amp;leds, &amp;leds, (NUM_LEDS-1) * sizeof(CRGB) );

    switch (ColorCounter) 
    {
      case 0: leds = Color3; break;
      case 1: leds = Color2; break;
      case 2: leds = Color1; break;
    }

    FastLED.show();
    
    BlockLEDCounter++;
    
    if (BlockLEDCounter==BlockWidth) 
    {
      BlockLEDCounter = 0;
      ColorCounter++;
      if (ColorCounter==NumberOfColors) {
        ColorCounter = 0;
      }
    }
    
    delay(WaveDelay);
  }
}</pre>
<p> </p>
<p> </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/led-effects-candy-cane/#post-2982</guid>
                    </item>
							        </channel>
        </rss>
		