Hello, I would like to add more functionality to the Demo Reel 100 example by adding a momentary toggle switch (ON/OFF/ON, springing back to OFF) that lets the viewer scroll through patterns. This would be in place of the timer which calls nextpattern() every “N” seconds. I’ve got the switch working great with the button library and the UP/Down example. The only thing I’m missing is how to use the size of the pattern array.
I understand how the modulo operator (%) uses the remainder to loop from the maximum array size back to zero when increasing to the next pattern using function nextpattern(). I tried creating another function called prevpattern(), but I’m having trouble decrementing from zero to the array size of the patterns variable. In my example, I have six patterns, so I would like it to decrement from zero to 5.
in my “non-smart” way of coding it, when I call prevpattern() I can test if the pattern number is zero and shove a 5 in there but I would like to make it so I can just add/remove patterns without changing this prevpattern() function.
Thanks in advance!
Platform: Arduino NANO
IDE: Arduino IDE 1.6.7
FastLED Version 3.1 (the latest one from last night)
Code: http://hastebin.com/levupapanu.erlang_repl