title: Animating to an array
body: <p>I have an Arduino, and I am trying to find the most efficient way to animate pixels in an array. The array is represented by 3 arrays of 30 <code>uint8_t</code>s. (30 pixels * R+G+B levels 0-255).</p>
  
  <p>What is the best way to move pixels down the array independently? This is a memory limited environment (2 KB RAM), and the array takes up 720 bytes. I had originally tried to use an array for each pixel, and ran out of memory. A second implementation used if statements, and it works well, but it is very tedious to make new patterns. I am looking for a way to solve the problem that may be better than how I am solving it now.</p>
  
  <p>Here's an example of a pattern I would like to animate.</p>
  
  <pre><code>X moves forward 1 each cycle.
  Y moves forward 3 places then back 2.
  Z moves backwards 3 places each cycle.
  
  |_|X|_|_|_|_|_|_|_|_|_|_|_|_|Y|_|_|_|_|_|_|_|_|_|_|_|_|_|_|Z|
  |_|_|X|_|_|_|_|_|_|_|_|_|_|_|_|_|_|Y|_|_|_|_|_|_|_|_|Z|_|_|_|
  |_|_|_|X|_|_|_|_|_|_|_|_|_|_|_|Y|_|_|_|_|_|_|_|Z|_|_|_|_|_|_|
  </code></pre>
  
  <p>And here's the code I would use.</p>
  
  <pre><code>void animateScene1() {
      for(int i = 0; i &lt;= numPixels; i++) {
          setColor(i, X);
          if(i &lt; 15) {
              if(i % 2 == 0)
                  setColor((i+15)+3), Y);
              else
                  setColor((i+15)-2), Y);
          }
          if(i &lt; 10)
              setColor(numPixels-3*i, Z);
      }
  }
  </code></pre>
  
  <p>Any ideas of better ways?</p>