#define L1RedPin 4 #define L1GreenPin 3 #define L1BluePin 2 void setup() { pinMode(L1RedPin, OUTPUT); pinMode(L1GreenPin, OUTPUT); pinMode(L1BluePin, OUTPUT); DisplayColor(0,0,0); } void loop() { Shades(); // RGB(); } void Shades() { unsigned int RGBColour[3]; RGBColour[0] = 255; RGBColour[1] = 0; RGBColour[2] = 0; for (int decColour = 0; decColour < 3; decColour += 1) { int incColour = decColour == 2 ? 0 : decColour + 1; // ANSWER = (YESNO) ? YES : NO; // cross-fade the two colours. for(int i = 0; i < 255; i += 1) { RGBColour[decColour] -= 1; RGBColour[incColour] += 1; DisplayColor(RGBColour[0], RGBColour[1], RGBColour[2]); delay(5); } } } void RGB() { DisplayColor(255,0,0); delay(1000); DisplayColor(0,255,0); delay(1000); DisplayColor(0,0,255); delay(1000); } void DisplayColor(byte R, byte G, byte B) { analogWrite(L1RedPin, R); analogWrite(L1GreenPin, G); analogWrite(L1BluePin, B); }