Untested.
Leo..
unsigned int potValue[5]; // five pots: dim=A0 red=A1 green=A2 blue=A3 white=A4
const byte redPin = 11, greenPin = 10, bluePin = 9, whitePin = 6;
byte redValue, greenValue, blueValue, whiteValue;
byte prevRed, prevGreen, prevBlue, prevWhite;
void setup() {
Serial.begin(115200);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(whitePin, OUTPUT);
}
void loop() {
for (byte i = 0; i < 5; i++) potValue[i] = analogRead(i) >> 2;
redValue = potValue[0] * potValue[1] / 255;
if (redValue != prevRed) {
analogWrite(redPin, redValue);
prevRed = redValue;
printRGBW();
}
greenValue = potValue[0] * potValue[2] / 255;
if (greenValue != prevGreen) {
analogWrite(greenPin, greenValue);
prevGreen = greenValue;
printRGBW();
}
blueValue = potValue[0] * potValue[3] / 255;
if (blueValue != prevBlue) {
analogWrite(bluePin, blueValue);
prevBlue = blueValue;
printRGBW();
}
whiteValue = potValue[0] * potValue[4] / 255;
if (whiteValue != prevWhite) {
analogWrite(whitePin, whiteValue);
prevWhite = whiteValue;
printRGBW();
}
}
void printRGBW() {
Serial.print("Dim:");
Serial.print(potValue[0]);
Serial.print(" Red:");
Serial.print(redValue);
Serial.print(" Green:");
Serial.print(greenValue);
Serial.print(" Blue:");
Serial.print(blueValue);
Serial.print(" White:");
Serial.println(whiteValue);
delay(100);
}