Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scroll to be an unsigned int #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DaveJWalker
Copy link

scroll needs to be an unsigned integer... otherwise, it'll roll over to a negative value and 'wreak havoc' when updating the LED array in the subsequent loop. On a 32-bit processor, the int value will range from +2^31-1 top -2^31, so the rollover won't occur for a LONG time. However, on a number of Arduino platforms, the int value will only be 16-bits... so it'll roll at 32K iterations.

(I commented in the YouTube video but decided to come here as well to propose the change.)

Cheers,
Dave

scroll needs to be an unsigned integer... otherwise, it'll roll over to a negative value and 'wreak havoc' when updating the LED array in the subsequent loop.  On a 32-bit processor, the int value will range from +2^31-1 top -2^31, so the rollover won't occur for a LONG time.  However, on a number of Arduino platforms, the int value will only be 16-bits... so it'll roll at 32K iterations.

(I commented in the YouTube video but decided to come here as well to propose the change.)

Cheers,
Dave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant