Question: Modify the Fading sketch code below to ramp an LED brightness exponentially. For the last fifth of the cycle max the brightness and then repeat

Modify the "Fading" sketch code below to ramp an LED brightness
exponentially. For the last fifth of the cycle max the brightness
and then repeat the cycle. Use a frequency of 500mHz (milli-Hertz). A general
plot of one cycle is shown below with normalized time and normalized
brightness.
int ledPin =9; // Pin connected to the LED
int brightness =0; // Initial brightness level (0 to 255)
int fadeAmount =5; // Amount to change the brightness by
void setup(){
// Set the LED pin as an output
pinMode (ledPin, OUTPUT);
}
void loop (){
// Set the brightness of the LED
analogWrite (ledPin, brightness);
// Change the brightness for the next loop
brightness = brightness + fadeAmount;
// Reverse the direction of the fade at the ends of the fade
if (brightness >=255){
brightness =0; // Reset
}
// Wait for 30 milliseconds before changing the brightness again
delay(30);
}
Modify the "Fading" sketch code below to ramp an

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!