<?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>
									Theatre chase in opposite directions. - Arduino				            </title>
            <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/</link>
            <description>Discussion board for Robotics, Arduino, Raspberry Pi and other DIY electronics and modules. Join us today!</description>
            <language>en-US</language>
            <lastBuildDate>Sat, 08 Aug 2026 19:12:36 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23950</link>
                        <pubDate>Sun, 16 Jan 2022 00:36:59 +0000</pubDate>
                        <description><![CDATA[@davy-ps 

How is this function actually applied in the context of this code. IE What does it do?
// == this is a function to swap values between two integer variables =====void swapInt(i...]]></description>
                        <content:encoded><![CDATA[<p>@davy-ps </p>
<blockquote>
<p>How is this function actually applied in the context of this code. IE What does it do?</p>
<p>// == this is a function to swap values between two integer variables =====<br />void swapInt(int &amp;a, int &amp;b) {<br />int c = a;<br />a = b;<br />b = c;<br />}</p>
</blockquote>
<p> </p>
<p>It swaps the values of color1 and color2.</p>
<p>// values before executing swapInt()</p>
<p>color1 == BLUE<br />color2 == YELLOW</p>
<p>swapInt(color1,color2)</p>
<p>// values after executing swapInt()</p>
<p>color1 == YELLOW<br />color2 == BLUE</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>robotBuilder</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23950</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23948</link>
                        <pubDate>Sun, 16 Jan 2022 00:32:41 +0000</pubDate>
                        <description><![CDATA[@lee-g 
Hi Lee. I started my electronics career around  three months ago. Trying like mad to get me head around programming. robotBuilder and Will have been a great support and freely givin...]]></description>
                        <content:encoded><![CDATA[<p>@lee-g </p>
<p>Hi Lee. I started my electronics career around  three months ago. Trying like mad to get me head around programming. robotBuilder and Will have been a great support and freely giving of their time and knowledge. Once I get to a level where I feel comfortable I am going to try and set up an ATMEGA chip to run independently of USB on breadboard powered by 2X9V batteries in parallel down through a 7805 IC to give me 5V. </p>
<p> </p>
<p>Cheers,</p>
<p>Davy.</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>Davy PS</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23948</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23947</link>
                        <pubDate>Sun, 16 Jan 2022 00:19:58 +0000</pubDate>
                        <description><![CDATA[@robotbuilder 
Hi Mate. Been going over your last code. Printed it off and noted changes to effects as I change values. 
I have one area where I am confused. (One that I&#039;m aware of anyway)...]]></description>
                        <content:encoded><![CDATA[<p>@robotbuilder </p>
<p>Hi Mate. Been going over your last code. Printed it off and noted changes to effects as I change values. </p>
<p>I have one area where I am confused. (One that I'm aware of anyway) ;-). </p>
<p><span style="color: #ff0000">How is this function actually applied in the context of this code. IE What does it do?</span></p>
<blockquote>
<p>// == this is a function to swap values between two integer variables =====<br />void swapInt(int &amp;a, int &amp;b) {<br />int c = a;<br />a = b;<br />b = c;<br />}</p>
</blockquote>
<p>I have attached entire code for reference point.</p>
<p> </p>
<p>Cheers,</p>
<p>Davy.</p>
<p> </p>
<pre contenteditable="false"><span style="color: #5e6d03">#include</span> <span style="color: #434f54">&lt;</span><strong><span style="color: #d35400">Adafruit_NeoPixel</span></strong><span style="color: #434f54">.</span><span style="color: #000000">h</span><span style="color: #434f54">&gt;</span> <span style="color: #434f54">//Indicates library is available for access.</span>
<span style="color: #5e6d03">#include</span> <span style="color: #434f54">&lt;</span><strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #000000">h</span><span style="color: #434f54">&gt;</span>           <span style="color: #434f54">//Indicates library is available for access.</span>

<span style="color: #5e6d03">#define</span> <span style="color: #000000">LED_PIN</span> <span style="color: #000000">4</span>     <span style="color: #434f54">//Arduino Ouput pin</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">NUM_LEDS</span> <span style="color: #000000">10</span>  <span style="color: #434f54">// Number of LEDS avaialble</span>

<span style="color: #5e6d03">#define</span> <span style="color: #000000">BLACK</span>  <span style="color: #000000">0</span>  <span style="color: #434f54">// Activates BLACK IE Switches led off.</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">RED</span>    <span style="color: #000000">1</span>  <span style="color: #434f54">// Activates RED</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">GREEN</span>  <span style="color: #000000">2</span>  <span style="color: #434f54">// Activates GREEN</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">BLUE</span>   <span style="color: #000000">3</span>  <span style="color: #434f54">// Activates BLUE</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">YELLOW</span> <span style="color: #000000">4</span>  <span style="color: #434f54">// Activates YELLOW</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">PURPLE</span> <span style="color: #000000">5</span>  <span style="color: #434f54">// Activates PURPLE</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">GRAY</span>   <span style="color: #000000">6</span>  <span style="color: #434f54">// Activates GRAY</span>

<strong><span style="color: #d35400">CRGB</span></strong> <span style="color: #000000">leds</span><span style="color: #000000"></span><span style="color: #000000">;</span> <span style="color: #434f54">// []Indicates an array. In this case 10 LEDS.</span>
<span style="color: #434f54">// NUM_LEDS could also be expressed as ;.</span>

<strong><span style="color: #d35400">CRGB</span></strong> <span style="color: #000000">colorList</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">{</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>     <span style="color: #434f54">// NO COLOR</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// RED</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// GREEN</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// BLUE</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span> <span style="color: #434f54">// YELLOW</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">102</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">51</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>  <span style="color: #434f54">// PURPLE</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">51</span><span style="color: #434f54">,</span><span style="color: #000000">51</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// GRAY</span>
                    <span style="color: #000000">}</span><span style="color: #000000">;</span>
<span style="color: #434f54">//CRGB colorList =. Array assigning colours to colour list.</span>
<span style="color: #434f54">//Each entry requires opening and closing curly brackets,</span>
<span style="color: #434f54">//with RGB values in parenthesis. Comma to complete after closing curly bracket.</span>
<span style="color: #434f54">//Comma acts as seperator.</span>
<span style="color: #434f54">//Curly brackets indicate start and end of function or statement. </span>
<span style="color: #434f54">//Must be used as a pair IE Opening and Closing {}.Highlighting</span>
<span style="color: #434f54">//one bracket in code will identify opposite bracket.</span>
<span style="color: #434f54">// Check that values in parenthesis align with colour nominated.</span>

                  
<span style="color: #434f54">// == this is a function to swap values between two integer variables  =====</span>
<span style="color: #00979c">void</span> <span style="color: #000000">swapInt</span><span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #434f54">&amp;</span><span style="color: #000000">a</span><span style="color: #434f54">,</span> <span style="color: #00979c">int</span> <span style="color: #434f54">&amp;</span><span style="color: #000000">b</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
  <span style="color: #00979c">int</span> <span style="color: #000000">c</span> <span style="color: #434f54">=</span> <span style="color: #000000">a</span><span style="color: #000000">;</span>
  <span style="color: #000000">a</span> <span style="color: #434f54">=</span> <span style="color: #000000">b</span><span style="color: #000000">;</span>
  <span style="color: #000000">b</span> <span style="color: #434f54">=</span> <span style="color: #000000">c</span><span style="color: #000000">;</span>
<span style="color: #000000">}</span>


<span style="color: #00979c">void</span> <span style="color: #5e6d03">setup</span><span style="color: #000000">(</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
  <strong><span style="color: #d35400">Serial</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">begin</span><span style="color: #000000">(</span><span style="color: #000000">9600</span><span style="color: #000000">)</span><span style="color: #000000">;</span> <span style="color: #434f54">// </span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">addLeds</span><span style="color: #434f54">&lt;</span><span style="color: #00979c">WS2812</span><span style="color: #434f54">,</span> <span style="color: #000000">LED_PIN</span><span style="color: #434f54">,</span> <span style="color: #00979c">GRB</span><span style="color: #434f54">&gt;</span><span style="color: #000000">(</span><span style="color: #000000">leds</span><span style="color: #434f54">,</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">setBrightness</span><span style="color: #000000">(</span><span style="color: #000000">100</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <span style="color: #434f54">// turn off all leds</span>
  <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber</span><span style="color: #434f54">++</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
      <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>  <span style="color: #434f54">// copy leds[] values to actual leds</span>
<span style="color: #000000">}</span>

<span style="color: #00979c">int</span> <span style="color: #000000">ledNumber2</span><span style="color: #000000">;</span>   <span style="color: #434f54">// working variable</span>

<span style="color: #00979c">int</span> <span style="color: #000000">color1</span><span style="color: #434f54">,</span> <span style="color: #000000">color2</span><span style="color: #000000">;</span>    <span style="color: #434f54">// stores two colors</span>
<span style="color: #00979c">int</span> <span style="color: #000000">loopCounter</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span>   <span style="color: #434f54">// counts times loop() is repeated</span>

<span style="color: #00979c">void</span> <span style="color: #5e6d03">loop</span><span style="color: #000000">(</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>

  <span style="color: #434f54">// decide what pair of colors to use for this loop() count</span>
  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
    <span style="color: #000000">color1</span> <span style="color: #434f54">=</span> <span style="color: #000000">BLUE</span><span style="color: #000000">;</span>
    <span style="color: #000000">color2</span> <span style="color: #434f54">=</span> <span style="color: #000000">RED</span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>

  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">1</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
    <span style="color: #000000">color1</span> <span style="color: #434f54">=</span> <span style="color: #000000">GREEN</span><span style="color: #000000">;</span>
   <span style="color: #000000">color2</span> <span style="color: #434f54">=</span> <span style="color: #000000">YELLOW</span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>

  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">2</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
   <span style="color: #000000">color1</span> <span style="color: #434f54">=</span> <span style="color: #000000">PURPLE</span><span style="color: #000000">;</span>
    <span style="color: #000000">color2</span> <span style="color: #434f54">=</span> <span style="color: #000000">GRAY</span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>

  <span style="color: #434f54">// update loopCounter</span>
  <span style="color: #000000">loopCounter</span> <span style="color: #434f54">=</span> <span style="color: #000000">loopCounter</span> <span style="color: #434f54">+</span> <span style="color: #000000">1</span><span style="color: #000000">;</span>
  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">3</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
    <span style="color: #000000">loopCounter</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span>        <span style="color: #434f54">// reset counter</span>
  <span style="color: #000000">}</span>

  <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span><span style="color: #434f54">++</span><span style="color: #000000">)</span>  <span style="color: #434f54">// for each led</span>
  <span style="color: #000000">{</span> 

    <span style="color: #434f54">// swap colors half way to give bounce off each other effect</span>
    <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">ledNumber1</span> <span style="color: #434f54">==</span> <span style="color: #000000">5</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
      <span style="color: #000000">swapInt</span><span style="color: #000000">(</span><span style="color: #000000">color1</span><span style="color: #434f54">,</span><span style="color: #000000">color2</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #000000">}</span>
    
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
    <span style="color: #000000">ledNumber2</span> <span style="color: #434f54">=</span> <span style="color: #000000">9</span> <span style="color: #434f54">-</span> <span style="color: #000000">ledNumber1</span><span style="color: #000000">;</span>
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
    <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">100</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span> <span style="color: #434f54">//turn off led</span>
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span> <span style="color: #434f54">//turn off led</span>
    <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">;</span> <span style="color: #434f54">//Time turned off.</span>
  <span style="color: #000000">}</span>

<span style="color: #000000">}</span>

</pre>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>Davy PS</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23947</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23907</link>
                        <pubDate>Wed, 12 Jan 2022 19:20:18 +0000</pubDate>
                        <description><![CDATA[@robotBuilder, @Will, @DavyPS
Thanks, gentlemen. I have been following along with this topic from the beginning. I even purchased a reel of neopixels to play with. Thanks very much to @robo...]]></description>
                        <content:encoded><![CDATA[<p>@robotBuilder, @Will, @DavyPS</p>
<p>Thanks, gentlemen. I have been following along with this topic from the beginning. I even purchased a reel of neopixels to play with. Thanks very much to @robotBuilder and @Will for their help and instructions in how to efficiently program this project. Very interesting… “wasted” many afternoons working on this. But, at 76, my days are not exactly filled with pressing matters.<span class="Apple-converted-space">  </span>Now trying to port it to RPi using Python. Will be trying to use two strips running independently lighting up the lights. (Hopefully… I don’t have it working yet).</p>
<p>Good Wishes to you and yours,</p>
<p>Lee</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>Lee G</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23907</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23902</link>
                        <pubDate>Wed, 12 Jan 2022 10:58:24 +0000</pubDate>
                        <description><![CDATA[@robotbuilder 
Thanks Mate. Programme runs perfectly. Will spend next few days digesting learnings. 
 
Cheers,
 
Davy.]]></description>
                        <content:encoded><![CDATA[<p>@robotbuilder </p>
<p>Thanks Mate. Programme runs perfectly. Will spend next few days digesting learnings. </p>
<p> </p>
<p>Cheers,</p>
<p> </p>
<p>Davy.</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>Davy PS</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/11/#post-23902</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23901</link>
                        <pubDate>Wed, 12 Jan 2022 10:44:34 +0000</pubDate>
                        <description><![CDATA[@davy-ps 

So the bouncing effect IE when one colour starts at 0 to 4 and second colour starts from 9 to 5 would look like this?
ledNumber1: 0 1 2 3 4 4 3 2 1 0ledNumber2: 9 8 7 6 5 5 6 7...]]></description>
                        <content:encoded><![CDATA[<p>@davy-ps </p>
<blockquote>
<p>So the bouncing effect IE when one colour starts at 0 to 4 and second colour starts from 9 to 5 would look like this?</p>
<p>ledNumber1: 0 1 2 3 4 4 3 2 1 0<br />ledNumber2: 9 8 7 6 5 5 6 7 8 9</p>
</blockquote>
<p>No. The colours just move all the way through each other. One left to right and the other right to left.</p>
<blockquote>
<p>How would I add a function to this code to give the effect of the LEDs bouncing off each other without using attached pattern?</p>
</blockquote>
<p><strong>The fun part of programming is working this out yourself :)</strong>  That means learning more about programming. For example making use of the conditional statement  if (this is true) do X else do Y</p>
<p>The method I used below, to give the bounce effect, uses variables, color1 and color2 to hold the colour numbers and swap their values half way through the for loop. I added a swapInt function to perform the swap task.</p>
<p>I have also added a loopCounter variable to count how many times the main loop() is executed. This is used to swap the colours.  The pair of colour variables are changed three times after which the loopCounter is reset to repeat the colour pairs again.</p>
<p>I can't run the program so I just hope it behaves as I think it will.</p>
<p> </p>
<p> </p>
<pre contenteditable="false"><span style="color: #5e6d03">#include</span> <span style="color: #434f54">&lt;</span><strong><span style="color: #d35400">Adafruit_NeoPixel</span></strong><span style="color: #434f54">.</span><span style="color: #000000">h</span><span style="color: #434f54">&gt;</span>
<span style="color: #5e6d03">#include</span> <span style="color: #434f54">&lt;</span><strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #000000">h</span><span style="color: #434f54">&gt;</span>

<span style="color: #5e6d03">#define</span> <span style="color: #000000">LED_PIN</span> <span style="color: #000000">4</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">NUM_LEDS</span> <span style="color: #000000">10</span>

<span style="color: #5e6d03">#define</span> <span style="color: #000000">BLACK</span>  <span style="color: #000000">0</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">RED</span>    <span style="color: #000000">1</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">GREEN</span>  <span style="color: #000000">2</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">BLUE</span>   <span style="color: #000000">3</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">YELLOW</span> <span style="color: #000000">4</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">PURPLE</span> <span style="color: #000000">5</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">GRAY</span>   <span style="color: #000000">6</span>

<strong><span style="color: #d35400">CRGB</span></strong> <span style="color: #000000">leds</span><span style="color: #000000"></span><span style="color: #000000">;</span>

<strong><span style="color: #d35400">CRGB</span></strong> <span style="color: #000000">colorList</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">{</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>     <span style="color: #434f54">// NO COLOR</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// RED</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// GREEN</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// BLUE</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span> <span style="color: #434f54">// YELLOW</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">102</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">51</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>  <span style="color: #434f54">// PURPLE</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">51</span><span style="color: #434f54">,</span><span style="color: #000000">51</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// GRAY</span>
                    <span style="color: #000000">}</span><span style="color: #000000">;</span>

<span style="color: #434f54">// == this is a function to swap values between two integer variables  =====</span>
<span style="color: #00979c">void</span> <span style="color: #000000">swapInt</span><span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #434f54">&amp;</span><span style="color: #000000">a</span><span style="color: #434f54">,</span> <span style="color: #00979c">int</span> <span style="color: #434f54">&amp;</span><span style="color: #000000">b</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
  <span style="color: #00979c">int</span> <span style="color: #000000">c</span> <span style="color: #434f54">=</span> <span style="color: #000000">a</span><span style="color: #000000">;</span>
  <span style="color: #000000">a</span> <span style="color: #434f54">=</span> <span style="color: #000000">b</span><span style="color: #000000">;</span>
  <span style="color: #000000">b</span> <span style="color: #434f54">=</span> <span style="color: #000000">c</span><span style="color: #000000">;</span>
<span style="color: #000000">}</span>


<span style="color: #00979c">void</span> <span style="color: #5e6d03">setup</span><span style="color: #000000">(</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
  <strong><span style="color: #d35400">Serial</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">begin</span><span style="color: #000000">(</span><span style="color: #000000">9600</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">addLeds</span><span style="color: #434f54">&lt;</span><span style="color: #00979c">WS2812</span><span style="color: #434f54">,</span> <span style="color: #000000">LED_PIN</span><span style="color: #434f54">,</span> <span style="color: #00979c">GRB</span><span style="color: #434f54">&gt;</span><span style="color: #000000">(</span><span style="color: #000000">leds</span><span style="color: #434f54">,</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">setBrightness</span><span style="color: #000000">(</span><span style="color: #000000">100</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <span style="color: #434f54">// turn off all leds</span>
  <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber</span><span style="color: #434f54">++</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
      <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>  <span style="color: #434f54">// copy leds[] values to actual leds</span>
<span style="color: #000000">}</span>

<span style="color: #00979c">int</span> <span style="color: #000000">ledNumber2</span><span style="color: #000000">;</span>   <span style="color: #434f54">// working variable</span>

<span style="color: #00979c">int</span> <span style="color: #000000">color1</span><span style="color: #434f54">,</span> <span style="color: #000000">color2</span><span style="color: #000000">;</span>    <span style="color: #434f54">// stores two colors</span>
<span style="color: #00979c">int</span> <span style="color: #000000">loopCounter</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span>   <span style="color: #434f54">// counts times loop() is repeated</span>

<span style="color: #00979c">void</span> <span style="color: #5e6d03">loop</span><span style="color: #000000">(</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>

  <span style="color: #434f54">// decide what pair of colors to use for this loop() count</span>
  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
    <span style="color: #000000">color1</span> <span style="color: #434f54">=</span> <span style="color: #000000">RED</span><span style="color: #000000">;</span>
    <span style="color: #000000">color2</span> <span style="color: #434f54">=</span> <span style="color: #000000">BLUE</span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>

  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">1</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
    <span style="color: #000000">color1</span> <span style="color: #434f54">=</span> <span style="color: #000000">GREEN</span><span style="color: #000000">;</span>
    <span style="color: #000000">color2</span> <span style="color: #434f54">=</span> <span style="color: #000000">YELLOW</span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>

  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">2</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
    <span style="color: #000000">color1</span> <span style="color: #434f54">=</span> <span style="color: #000000">PURPLE</span><span style="color: #000000">;</span>
    <span style="color: #000000">color2</span> <span style="color: #434f54">=</span> <span style="color: #000000">GRAY</span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>

  <span style="color: #434f54">// update loopCounter</span>
  <span style="color: #000000">loopCounter</span> <span style="color: #434f54">=</span> <span style="color: #000000">loopCounter</span> <span style="color: #434f54">+</span> <span style="color: #000000">1</span><span style="color: #000000">;</span>
  <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">loopCounter</span> <span style="color: #434f54">==</span> <span style="color: #000000">3</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
    <span style="color: #000000">loopCounter</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span>        <span style="color: #434f54">// reset counter</span>
  <span style="color: #000000">}</span>

  <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span><span style="color: #434f54">++</span><span style="color: #000000">)</span>  <span style="color: #434f54">// for each led</span>
  <span style="color: #000000">{</span> 

    <span style="color: #434f54">// swap colors half way to give bounce off each other effect</span>
    <span style="color: #5e6d03">if</span> <span style="color: #000000">(</span><span style="color: #000000">ledNumber1</span> <span style="color: #434f54">==</span> <span style="color: #000000">5</span><span style="color: #000000">)</span><span style="color: #000000">{</span>
      <span style="color: #000000">swapInt</span><span style="color: #000000">(</span><span style="color: #000000">color1</span><span style="color: #434f54">,</span><span style="color: #000000">color2</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #000000">}</span>
    
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
    <span style="color: #000000">ledNumber2</span> <span style="color: #434f54">=</span> <span style="color: #000000">9</span> <span style="color: #434f54">-</span> <span style="color: #000000">ledNumber1</span><span style="color: #000000">;</span>
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
    <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span> <span style="color: #434f54">//turn off led</span>
    <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
    <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
    <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>

<span style="color: #000000">}</span>

</pre>
<p> </p>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>robotBuilder</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23901</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23900</link>
                        <pubDate>Wed, 12 Jan 2022 10:13:01 +0000</pubDate>
                        <description><![CDATA[@robotbuilder 
Mate, further to my previous post....

With your last example you a mixing methods (look up table for values to use vs algorithm to generate those values). I would recommen...]]></description>
                        <content:encoded><![CDATA[<p>@robotbuilder </p>
<p>Mate, further to my previous post....</p>
<blockquote>
<p>With your last example you a mixing methods (look up table for values to use vs algorithm to generate those values). I would recommend that you learn to use algorithms. Lists and tables have a use but they aren't teaching you how to improve your programming.</p>
<p>For example if you want two different colours to pass each other you might think how to compute the second led position from the position of the led moving right.</p>
<p>ledNumber1: 0 1 2 3 4 5 6 7 8 9<br />ledNumber2: 9 8 7 6 5 4 3 2 1 0</p>
<p>Notice that ledNumber2 = 9 - ledNumber1</p>
<p>In this example the red moves left to right while the green moves right to left. This is repeated.</p>
</blockquote>
<p>So the bouncing effect IE when one colour starts at 0 to 4 and second colour starts from 9 to 5 would look like this?</p>
<p>ledNumber1: 0 1 2 3 4 4 3 2 1 0<br />ledNumber2: 9 8 7 6 5 5 6 7 8 9</p>
<p>If so, how is this applied?</p>
<p>Thanks,</p>
<p>Davy.</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>Davy PS</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23900</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23899</link>
                        <pubDate>Wed, 12 Jan 2022 08:30:28 +0000</pubDate>
                        <description><![CDATA[@robotbuilder 
Hi Mate thanks for this code. A lot easier to work with colours. One thing I&#039;d like to ask;
How would I add a function to this code to give the effect of the LEDs bouncing o...]]></description>
                        <content:encoded><![CDATA[<p>@robotbuilder </p>
<p>Hi Mate thanks for this code. A lot easier to work with colours. One thing I'd like to ask;</p>
<p>How would I add a function to this code to give the effect of the LEDs bouncing off each other without using attached pattern? I have tried a few things but can only get them to run one way IE from led 5-9 and then restarting from 5 again.</p>
<p>Cheers,</p>
<p> </p>
<p>Davy.</p>
<p> </p>
<p>int patterns = {{1,0,0,0,0,0,0,0,0,2},<br />{0,1,0,0,0,0,0,0,2,0},<br />{0,0,1,0,0,0,0,2,0,0},<br />{0,0,0,1,0,0,2,0,0,0},<br />{0,0,0,0,1,2,0,0,0,0},<br />{0,0,0,0,1,2,0,0,0,0},<br />{0,0,0,1,0,0,2,0,0,0},<br />{0,0,1,0,0,0,0,2,0,0},<br />{0,1,0,0,0,0,0,0,2,0},<br />{1,0,0,0,0,0,0,0,0,2},<br />{0,1,0,0,0,0,0,0,2,0},<br />{0,0,1,0,0,0,0,2,0,0},<br />{0,0,0,1,0,0,2,0,0,0},<br />{0,0,0,0,1,2,0,0,0,0},<br />{0,0,0,0,1,2,0,0,0,0},<br />{0,0,0,1,0,0,2,0,0,0},<br />{0,0,1,0,0,0,0,2,0,0},<br />{0,1,0,0,0,0,0,0,2,0}};</p>
<p> </p>
<p> </p>
<pre contenteditable="false"><span style="color: #5e6d03">#include</span> <span style="color: #434f54">&lt;</span><strong><span style="color: #d35400">Adafruit_NeoPixel</span></strong><span style="color: #434f54">.</span><span style="color: #000000">h</span><span style="color: #434f54">&gt;</span>
<span style="color: #5e6d03">#include</span> <span style="color: #434f54">&lt;</span><strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #000000">h</span><span style="color: #434f54">&gt;</span>

<span style="color: #5e6d03">#define</span> <span style="color: #000000">LED_PIN</span> <span style="color: #000000">4</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">NUM_LEDS</span> <span style="color: #000000">10</span>

<span style="color: #5e6d03">#define</span> <span style="color: #000000">BLACK</span>  <span style="color: #000000">0</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">RED</span>    <span style="color: #000000">1</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">GREEN</span>  <span style="color: #000000">2</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">BLUE</span>   <span style="color: #000000">3</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">YELLOW</span> <span style="color: #000000">4</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">PURPLE</span>   <span style="color: #000000">5</span>
<span style="color: #5e6d03">#define</span> <span style="color: #000000">GRAY</span> <span style="color: #000000">6</span>
<strong><span style="color: #d35400">CRGB</span></strong> <span style="color: #000000">leds</span><span style="color: #000000"></span><span style="color: #000000">;</span>

<strong><span style="color: #d35400">CRGB</span></strong> <span style="color: #000000">colorList</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">{</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>     <span style="color: #434f54">// NO COLOR</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// RED</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// GREEN</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// BLUE</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">255</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span> <span style="color: #434f54">// YELLOW</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">102</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #434f54">,</span><span style="color: #000000">51</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// PURPLE</span>
                     <span style="color: #000000">{</span><strong><span style="color: #d35400">CRGB</span></strong><span style="color: #000000">(</span><span style="color: #000000">51</span><span style="color: #434f54">,</span><span style="color: #000000">51</span><span style="color: #434f54">,</span><span style="color: #000000">0</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #434f54">,</span>   <span style="color: #434f54">// GRAY</span>
                    <span style="color: #000000">}</span><span style="color: #000000">;</span>

<span style="color: #00979c">void</span> <span style="color: #5e6d03">setup</span><span style="color: #000000">(</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
  <strong><span style="color: #d35400">Serial</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">begin</span><span style="color: #000000">(</span><span style="color: #000000">9600</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">addLeds</span><span style="color: #434f54">&lt;</span><span style="color: #00979c">WS2812</span><span style="color: #434f54">,</span> <span style="color: #000000">LED_PIN</span><span style="color: #434f54">,</span> <span style="color: #00979c">RGB</span><span style="color: #434f54">&gt;</span><span style="color: #000000">(</span><span style="color: #000000">leds</span><span style="color: #434f54">,</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">setBrightness</span><span style="color: #000000">(</span><span style="color: #000000">100</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
  <span style="color: #434f54">// turn off all leds</span>
  <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber</span><span style="color: #434f54">++</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>
      <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
  <span style="color: #000000">}</span>
  <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>  <span style="color: #434f54">// copy leds[] values to actual leds</span>
<span style="color: #000000">}</span>

<span style="color: #00979c">int</span> <span style="color: #000000">ledNumber2</span><span style="color: #000000">;</span>   <span style="color: #434f54">// working variable</span>

<span style="color: #00979c">void</span> <span style="color: #5e6d03">loop</span><span style="color: #000000">(</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>

      <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span><span style="color: #434f54">++</span><span style="color: #000000">)</span>  <span style="color: #434f54">// for each led</span>
      <span style="color: #000000">{</span>       
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
        <span style="color: #000000">ledNumber2</span> <span style="color: #434f54">=</span> <span style="color: #000000">9</span> <span style="color: #434f54">-</span> <span style="color: #000000">ledNumber1</span><span style="color: #000000">;</span>
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
        <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span> <span style="color: #434f54">//turn off led</span>
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
        <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
      <span style="color: #000000">}</span>

      
        <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span><span style="color: #434f54">++</span><span style="color: #000000">)</span>  <span style="color: #434f54">// for each led</span>

        <span style="color: #000000">{</span>
         <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
         <span style="color: #000000">ledNumber2</span> <span style="color: #434f54">=</span> <span style="color: #000000">9</span> <span style="color: #434f54">-</span> <span style="color: #000000">ledNumber1</span><span style="color: #000000">;</span>
         <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
        <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span> <span style="color: #434f54">//turn off led</span>
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
        <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>

       
      <span style="color: #000000">}</span>
      
     <span style="color: #5e6d03">for</span> <span style="color: #000000">(</span><span style="color: #00979c">int</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">=</span> <span style="color: #000000">0</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span> <span style="color: #434f54">&lt;</span> <span style="color: #000000">NUM_LEDS</span><span style="color: #000000">;</span> <span style="color: #000000">ledNumber1</span><span style="color: #434f54">++</span><span style="color: #000000">)</span>  <span style="color: #434f54">// for each led </span>
<span style="color: #000000">{</span>
  
         <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
         <span style="color: #000000">ledNumber2</span> <span style="color: #434f54">=</span> <span style="color: #000000">9</span> <span style="color: #434f54">-</span> <span style="color: #000000">ledNumber1</span><span style="color: #000000">;</span>
         <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
        <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span> <span style="color: #434f54">//turn off led</span>
        <span style="color: #000000">leds</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">colorList</span><span style="color: #000000"></span><span style="color: #000000">;</span>
        <strong><span style="color: #d35400">FastLED</span></strong><span style="color: #434f54">.</span><span style="color: #d35400">show</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
        <span style="color: #d35400">delay</span><span style="color: #000000">(</span><span style="color: #000000">400</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
<span style="color: #000000">}</span>
<span style="color: #000000">}</span>


        

</pre>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>Davy PS</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23899</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23896</link>
                        <pubDate>Tue, 11 Jan 2022 23:20:17 +0000</pubDate>
                        <description><![CDATA[@robotbuilder 
 
Neopixel demonstration starts around 25-00]]></description>
                        <content:encoded><![CDATA[<p>@robotbuilder </p>
<p>https://www.youtube.com/watch?v=JpEFAXenTyY&amp;t=1918s&amp;ab_channel=DroneBotWorkshop</p>
<p> </p>
<p>Neopixel demonstration starts around 25-00</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>Davy PS</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23896</guid>
                    </item>
				                    <item>
                        <title>RE: Theatre chase in opposite directions.</title>
                        <link>https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23895</link>
                        <pubDate>Tue, 11 Jan 2022 23:14:36 +0000</pubDate>
                        <description><![CDATA[@davy-ps 
Missed that one!  I didn&#039;t know you could buy individual addressable rgb leds or that Bill had covered the topic.  Making colour led displays just wasn&#039;t on my radar.]]></description>
                        <content:encoded><![CDATA[<p>@davy-ps </p>
<p>Missed that one!  I didn't know you could buy individual addressable rgb leds or that Bill had covered the topic.  Making colour led displays just wasn't on my radar.</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/arduino/">Arduino</category>                        <dc:creator>robotBuilder</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/arduino/theatre-chase-in-opposite-directions/paged/10/#post-23895</guid>
                    </item>
							        </channel>
        </rss>
		