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:
parent
e90cf55143
commit
df8d22a440
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user