#define RED_PIN 11      // where the red pin is connected to
#define GREEN_PIN 10   // where the green pin is connected to
#define BLUE_PIN 9    // where the blue pin is connected to
#define RED2_PIN 8      // where the red pin is connected to
#define GREEN2_PIN 7   // where the green pin is connected to
#define BLUE2_PIN 6    // where the blue pin is connected to
#define RED3_PIN 5      // where the red pin is connected to
#define GREEN3_PIN 4   // where the green pin is connected to
#define BLUE3_PIN 3    // where the blue pin is connected to
#define DELAY 10       // 10ms internal delay; increase for slower fades
void setup() {
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN2_PIN, OUTPUT);
  pinMode(BLUE2_PIN, OUTPUT);
  pinMode(RED2_PIN, OUTPUT);
  pinMode(GREEN3_PIN, OUTPUT);
  pinMode(BLUE3_PIN, OUTPUT);
  pinMode(RED3_PIN, OUTPUT);
}
void loop() {
  // fade from green to red
  for(int i=0; i<255; i++) {
    analogWrite(RED_PIN, i);analogWrite(RED2_PIN, 0);analogWrite(RED3_PIN, 255-i);
    analogWrite(GREEN_PIN, 255-i);analogWrite(GREEN2_PIN, i);analogWrite(GREEN3_PIN, 0);
    analogWrite(BLUE_PIN, 0);analogWrite(BLUE2_PIN, 255-i);analogWrite(BLUE3_PIN, i);
    delay(DELAY);
  }
  // fade from red to blue
  for(int i=0; i<255; i++) {
    analogWrite(RED_PIN, 255-i);analogWrite(RED2_PIN, i);analogWrite(RED3_PIN, 0);
    analogWrite(GREEN_PIN, 0);analogWrite(GREEN2_PIN, 255-i);analogWrite(GREEN3_PIN, i);
    analogWrite(BLUE_PIN, i);analogWrite(BLUE2_PIN, 0);analogWrite(BLUE3_PIN, 255-i);
    delay(DELAY);
  }
  // fade from blue to green
  for(int i=0; i<255; i++) {
    analogWrite(RED_PIN, 0);analogWrite(RED2_PIN, 255-i);analogWrite(RED3_PIN, i);
    analogWrite(GREEN_PIN, i);analogWrite(GREEN2_PIN, 0);analogWrite(GREEN3_PIN, 255-i);
    analogWrite(BLUE_PIN, 255-i);analogWrite(BLUE2_PIN, i);analogWrite(BLUE3_PIN, 0);
    delay(DELAY);
  }
}
Comments