1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-20 14:54:31 +01:00

fix the boundary check

..so that changing fadeAmount (to, say, 7) doesn't break the algorithm making an infinit loop (see https://github.com/arduino/Arduino/issues/5115)
This commit is contained in:
YakovL 2016-07-10 18:31:42 +03:00 committed by GitHub
parent e90cf55143
commit df8d22a440

View File

@ -32,8 +32,8 @@ void loop() {
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);