Okay, super oddball question/mystery.

Okay, super oddball question/mystery.

I am using FastLED on Adafruit’s lovely Circuit Playground; It has 10 neopixels on board in a ring. I have been running many of the excellent code examples from this group on it to great effect, and have started digging in to make some of my own animations and patterns.

I was playing around with code from J Hendy’s blog (@ http://jwhendy.blogspot.com/2015/10/fastled-series-back-and-forth.html ) and managed to (badly) make a sketch that appears to upload okay, but then refuses to execute AND (weirdly) takes the ACP board right out of the Arduino’s port list, making subsequent uploads impossible until you put the board in bootloader mode (by double-tapping the reset button when the IDE is running through the possible ports) while uploading a short sketch…this reliably fixes the problem and the board shows back up.

Here’s a listing of the code:
http://pastebin.com/eUkbYqE9

Does anybody know why using ‘lead_dot -1’ has such a catastrophic effect?

Arduino IDE 1.6.10, OS X, FastLED 3.1

Thanks!
Chad

Because sometimes, lead_dot will be 0 - which means lead_dot - 1 will be -1 - which will basically cause the int value to wrap around to something large and cause you to over-write completely random parts of memory, corrupting the system.

You don’t want to do “lead_dot - 1” in there when lead_dot is 0.

Aha. Thanks for the clear explanation.