Go Down

Topic: What's wrong with my library...? (Read 3193 times) previous topic - next topic


Since the sketch works fine when the increment is 1, I would change the type of the loop variable from byte to int.

I suspect that what is happening is that, when the for loop variable gets incremented, by 2 for instance, that it gets set to 0, 2, 4, ..., 254. The next increment operation tries to set the variable to 256, which causes an overflow, and the value ends up at 0. It goes through the loop again with values of 0, 2, 4, ... 254. The increment and overflow occurs again, and the loop repeats.

Changing the loop variable type to int would prevent this problem.
The art of getting good answers lies in asking good questions.


It worked. Thanks so much!

I was following the LED library example by using "byte" in mine.
Thanks for the help

Go Up