From 6fb2b3023c0a4a786191ca04b9b4c411b784caad Mon Sep 17 00:00:00 2001 From: Shreyas Minocha Date: Tue, 16 Feb 2021 00:04:39 -0600 Subject: [PATCH] Fix Fade example potential bug With fade amounts that don't divide 255, the direction reversing won't work. --- build/shared/examples/01.Basics/Fade/Fade.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/shared/examples/01.Basics/Fade/Fade.ino b/build/shared/examples/01.Basics/Fade/Fade.ino index 6c70c91a43c..acd5f5b6d39 100644 --- a/build/shared/examples/01.Basics/Fade/Fade.ino +++ b/build/shared/examples/01.Basics/Fade/Fade.ino @@ -27,7 +27,7 @@ void loop() { brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: - if (brightness == 0 || brightness == 255) { + if (brightness <= 0 || brightness >= 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect