const int led = 9;
const int ledtwo = 8; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
pinMode(ledtwo, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness >= 0 || brightness >= 255) {
fadeAmount = -fadeAmount ;
}
analogWrite(ledtwo, brightness);
// change the brightness for next time through the loop:
brightness = brightness - fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}