// Define Pins #define RED 3 #define GREEN 5 #define BLUE 6 void setup() { // Initialize Pins As Output pinMode(RED, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BLUE, OUTPUT); } // Main Loop void loop() { // Define Color Level Variables int redValue = 0; // Valid Values Between 0 and 255 int greenValue = 0; int blueValue = 0; for (int c = 1; c < 4; c += 1) // Loop 3 times for the 3 colors { for (int i = 0; i < 256; i += 1) // Fades one color to the next { if (c == 1) { redValue = (255 - i); greenValue = i; } if (c == 2) { greenValue = (255 - i); blueValue = i; } if (c == 3) { blueValue = (255 - i); redValue = i; } analogWrite(RED, redValue); analogWrite(GREEN, greenValue); analogWrite(BLUE, blueValue); delay(10); } // Fade complete, pause on single full color for 1 second analogWrite(RED, redValue); analogWrite(GREEN, greenValue); analogWrite(BLUE, blueValue); delay(1000); } }