// Define the pin numbers
int reds[] = {13, 10, 7, 4};
int greens[] = {12, 9, 6, 3};
int blues[] = {11, 8, 5, 2};
int potPins[] = {A0, A1, A2}; // Connect your potentiometers to analog pins A0, A1, and A2
void setup() {
// Set all the pins as OUTPUT
for (int i = 0; i < 4; i++) {
pinMode(reds[i], OUTPUT);
pinMode(greens[i], OUTPUT);
pinMode(blues[i], OUTPUT);
}
}
void loop() {
// Read the potentiometer values
int potValue0 = analogRead(potPins[0]);
int potValue1 = analogRead(potPins[1]);
int potValue2 = analogRead(potPins[2]);
// Map the first potentiometer value to the number of LEDs
int numLEDs = map(potValue0, 0, 1023, 0, 4);
// Map the second potentiometer value to a color
int color = map(potValue1, 0, 1023, 0, 3);
// Map the third potentiometer value to a delay time
int delayTime = map(potValue2, 0, 1023, 50, 1000);
// Turn off all LEDs
for (int i = 0; i < 4; i++) {
digitalWrite(reds[i], LOW);
digitalWrite(greens[i], LOW);
digitalWrite(blues[i], LOW);
}
// Turn on the selected LEDs with the selected color
for (int i = 0; i < numLEDs; i++) {
if (color == 0) {
digitalWrite(reds[i], HIGH);
} else if (color == 1) {
digitalWrite(greens[i], HIGH);
} else if (color == 2) {
digitalWrite(blues[i], HIGH);
}
delay(delayTime);
digitalWrite(reds[i], LOW);
digitalWrite(greens[i], LOW);
digitalWrite(blues[i], LOW);
}
}