works standalone, no work as function

I have a sketch that lights 5 LED boards with port expanders. Stand-alone, the program works as intended, lighting up all the LEDS, in sequence, like a chaser, on the perimeter of my star shape.

As I have done with other sketches, I run them stand-alone, then copy and paste the relevant code into a larger sketch as a function, where I will run all functions in some kind of sequence.

To make sure it works, after I do the cut and paste, I uncomment only the function under test so only it runs. Well it doesn’t run. Other sketches-turned-to-functions DO WORK, but this particular one does not.

I’ve attached the MAIN sketch with the function locate at line 329. It is called “PointsCCWrot”, the same as the sketch name, also attached.

I’ve checked all the setup parameters and they are okay, maybe a little confusion with declaring variables, but changing these latter items don’t fix the problem.

Strange too is that only device 24 lights up and if I comment this out so that program has to run device 23 or any other, STILL 24 lights up.

I can’t see having timing problems or memory problems. I’m only running the one function, the same as the one sketch (pointsCCWrot).

PointsCCWrot.ino (1.8 KB)

MAIN.ino (12 KB)

All I can see is this:

  1. in the loop() you call PointsCCWRot() not PointsCCWrot() which is much closer to your original standalone working function.

  2. You additionally call PentagonCollapse() in the loop() which again introduces a difference to the working function.

  3. It is probably not the problem here, but you declare i and j globally and also locally in functions. It increases the risk of an error which the compiler will not catch.

Thanks 6V6 (I know the tube well)!

I can't believe it!! your #1 solution above was correct. "Rot" is not the same as "rot". The entire sketch/function didn't work because of a "case" issue.

I'm learning valuable lessons here. (newbie to Arduino and C++).

Thanks again for replying. You saved me lots of grief.

I'll look at the other two issues you brought up.

If you're happy with your solution, give @6 some karma and kindly edit your original message to include [SOLVED] in the subject line. Saves me (and others) from popping in unnecessarily. Thanks.