//CHALLENGE 2A//
//Change the rate of the fading in and out.//
//Use 2 (or more) LEDs – so that one fades in as the other one fades out.
//intialization//
int redLed = 3;
int yellowLed = 9;
int cyanLed = 10;
int brightness = 0;
int fadeAmount = 5;
//setup LED as output device//
void setup() {
pinMode(redLed, OUTPUT);
pinMode(yellowLed, OUTPUT);
pinMode(cyanLed, OUTPUT);
}
void loop() {
analogWrite(redLed, brightness);
analogWrite(yellowLed, 255 - brightness);// Yellow LED fades in reverse
analogWrite(cyanLed, 150 - brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// Change this delay to adjust the fading speed
delay(25); // Faster fading
}