Question: Edit the following Arduino Mega code so that the LED fades in and out on an infinite loop. The brightness level should be between 0

Edit the following Arduino Mega code so that the LED fades in and out on an infinite loop. The brightness level should be between 0 and 255. Modify your code such that you can use one push button to increase the light intensity of the LED and a second push button to decrease the intensity. Changes in intensity should occur when the buttons are released. Use pin 9 for the LED, pin 22 for the increase button, and pin 23

for the decrease button. When either button is pressed and released, change the brightness by an amount fade.

int led = 9;

void setup() {

pinMode(led, OUTPUT) ;

}

void loop() {

analongWrite(led,brightness);

}

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 Databases Questions!