Complete the code to set the LED brightness using PWM.
analogWrite(LED_PIN, [1]);The analogWrite function sets the brightness of the LED by using a value between 0 (off) and 255 (full brightness).
Complete the code to define the LED pin as output in setup().
pinMode([1], OUTPUT);The pinMode function sets the pin mode. We use LED_PIN to refer to the LED's pin.
Fix the error in the loop to gradually increase brightness.
for (int brightness = 0; brightness <= 255; brightness [1]) { analogWrite(LED_PIN, brightness); delay(10); }
The ++ operator increases the brightness by 1 each loop, creating a smooth fade-in effect.
Fill both blanks to create a loop that fades LED brightness up.
for (int brightness = 0; brightness [1] 255; brightness [2]) { analogWrite(LED_PIN, brightness); delay(10); }
The loop runs while brightness is less than or equal to 255, increasing brightness by 1 each time.
Fill all three blanks to create a complete fade-in and fade-out loop.
for (int brightness = 0; brightness [1] 255; brightness [2]) { analogWrite(LED_PIN, brightness); delay(10); } for (int brightness = 255; brightness [3] 0; brightness--) { analogWrite(LED_PIN, brightness); delay(10); }
The first loop increases brightness from 0 to 255, the second loop decreases brightness from 255 down to 0.
