This code was written by me.

In other words the work of a novice and while critique can be helpful, please be kind!

#include <Arduino.h>
/* Bill Grout 01/2023
Using MEGA board
  Organic pulse fade with 7 led’s on PWM
  Random choice of delaySet between flashes
  One RGB base led on pot 4
  Three dial inputs to control effects
    Control base RGB color
    Delay at Flash 20,400
    Delay at fade while loop 1,40
  fadeRate = Fixed at 10
*/
int ledPin[7] = {5,6,7,8,9,10,11};
int delaySet[4] = {50,200,400,800};
int randomLED;
int randomDelay;
int fadeRate = 10;
int newFade;
                   
int rgbRedPin = 2;            
int rgbBluePin = 4;
int rgbGreenPin = 3;
int red;
int blue;
int green;
void setup() {
  pinMode(rgbRedPin, OUTPUT);        
  pinMode(rgbBluePin, OUTPUT);
  pinMode(rgbGreenPin, OUTPUT);                  
 
  for (int i = 0; i < 7; i++) {        
    pinMode(ledPin[i], OUTPUT);
  }
 
 for (int i = 0; i < 7; i++) {
  analogWrite(ledPin[i], 10);        
  }
}
void loop() {  
 
  int potentiometerValue = analogRead(A0);
  int rgbValue = map(potentiometerValue, 0, 1023, 0, 1275);
 
  if (rgbValue < 256) {
    red = 255;
    green = rgbValue;
    blue = 0;
  }
  else if (rgbValue < 512) {
    red = 511 – rgbValue;
    green = 255;
    blue = 0;
  }
  else if (rgbValue < 768) {
    red = 0;
    green = 255;
    blue = rgbValue – 767;
  }
  else if (rgbValue < 1024) {
    red = 0;
    green = 1023 – rgbValue;
    blue = 255;
  }
      else {
    red = rgbValue – 1279;
    green = 0;
    blue = 255;
  }
   
  analogWrite(rgbRedPin, 255 – red);              // Common Anode RGB led reversed PWM
  analogWrite(rgbBluePin, 255 – blue);            //
  analogWrite(rgbGreenPin, 255 – green);          //
 
  int pot2 = analogRead(A1);
  int pot3 = analogRead(A2);
  int delayPot2flash = map(pot2, 0, 1023, 20, 400); // Range of flash ON time
  int delayPot3fade = map(pot3, 0, 1023, 1, 40);   // Range of delay between fade steps
    randomLED = ledPin[random (0,7)];
   
    analogWrite(randomLED, 255);                   // Flash
    delay(delayPot2flash);                         // Dwell of flash
    newFade = 255;  
    for (int i = 0; i < 100; i++) {
      while (newFade > 0){
       analogWrite(randomLED, newFade);  
       newFade = (newFade – fadeRate);
       delay(delayPot3fade);                       // Speed of overall effect
      }  
    }
  randomDelay = delaySet[random (0,4)];
  delay(randomDelay);
}