From 6a2ab076e2cd75ee4b2d0e422de56c9179d1f623 Mon Sep 17 00:00:00 2001 From: Dave <83719612+DaveJWalker@users.noreply.github.com> Date: Tue, 2 Nov 2021 14:40:55 -0700 Subject: [PATCH] Update scroll to be an unsigned int 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 --- LED Episode 06/src/marquee.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LED Episode 06/src/marquee.h b/LED Episode 06/src/marquee.h index 3c4fa35..84be887 100644 --- a/LED Episode 06/src/marquee.h +++ b/LED Episode 06/src/marquee.h @@ -57,7 +57,7 @@ void DrawMarqueeMirrored() } - static int scroll = 0; + static unsigned int scroll = 0; scroll++; for (int i = scroll % 5; i < NUM_LEDS / 2; i += 5)