int redPin = 11;
int greenPin = 10;
int bluePin = 9;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, LOW);
}
int redValue;
int greenValue;
int blueValue;
void loop() {
#define delayTime 10
for (int i = 0; i < 255; i += 1) {
redValue -= 1;
greenValue += 1;
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
delay(delayTime);
}
redValue = 0;
greenValue = 255;
blueValue = 0;
for (int i = 0; i < 255; i += 1) {
greenValue -= 1;
blueValue += 1;
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
delay(delayTime);
}
redValue = 0;
greenValue = 0;
blueValue = 255;
for (int i = 0; i < 255; i += 1) {
blueValue -= 1;
redValue += 1;
analogWrite(bluePin, blueValue);
analogWrite(redPin, redValue);
delay(delayTime);
}
}