Adding Potentiometer to control an 8 channel relay.

I have written a sketch for arduino that reads data coming in from Vixen to control some string lights attatched to an 8 channel relay switch. The program works fine. Now I need to know how to add a potentiometer into the mix so that after vixen is done playing its sequence, I can use the potentiometer to just turn on the lights by themselves.

int numberOfRelays = 8;
int relay[] = {2, 3, 4, 5, 6, 7, 8, 9};


#define MAX_CHANNELS 8
 
int ch;
int state;
int chVal[MAX_CHANNELS] = {0};
int pins[] = {2, 3, 4, 5, 6, 7, 8, 9};

enum states
{
  IDLE,
  DELIM,
  READ,
  DISP
};
 
void setup()
{
  for (ch=0; ch<MAX_CHANNELS; ch++)
  {
    pinMode(pins[ch], OUTPUT);
    digitalWrite(pins[ch], LOW);
   }
  
  state = IDLE;
  ch = 0;
  
  Serial.begin(115200);
}

 
void loop(){
  
  if (Serial.available())
  {
    switch (state)
    {
      case IDLE:  
        ch = 0;
        if (Serial.read() == '+')
        {
          state = DELIM;          
        }
        else
        {
          state = IDLE;
        }
      break;
        
      case DELIM:
        ch = 0;
        if (Serial.read() == '>')
        {
          state = READ;
        }
        else
        {
          state = IDLE;
        }
      break;
      
      case READ:
        chVal[ch++] = Serial.read();
        if (ch >= MAX_CHANNELS)
        {
          ch = 0;
          state = DISP;
        }
      break; 
      
      case DISP:
        state = IDLE;
        for (ch=0; ch<MAX_CHANNELS; ch++)
        {   
          //analogWrite(pins[ch], chVal[ch]); // Write current values to LED pins  
         
          
          if (chVal[ch] > 0)
          {
            digitalWrite(pins[ch], HIGH);
          }
          else
          {
            digitalWrite(pins[ch], LOW);
          }
          
        }
      break;
    }
  }
}

I need to know how to add a potentiometer into the mix so that after vixen is done playing its sequence, I can use the potentiometer to just turn on the lights by themselves.

Do you mean a potentiometer or switch?

If you mean a potentiometer, how do you want the relays to respond?

You could use the analog value from the potentiometer to turn on a relay when it is within a certain range.

1024/8 = 128

0 thru 127 turns on the 1st relay, 128 thru 255 tuns on the 2nd relay, 256 thru 511 turns on the 3rd relay, etc.

I literally want it to be able to just turn all the lights on at once at the end of the sequence. (Imagine, Running a light show synchronized to music through vixen. After the light show is over, I do not want to run anymore sequences but still want to be able to turn on all the lights just by turning the potentiometer all the way on.)

turn on all the lights just by turning the potentiometer all the way on.

When your sketch is at a point where your code enables the reading of the potentiometer and when you turn the pot to the position where you want the lights to come on ex: 512 or >= 1000 you simply do digitalWrites()s to each relay to turn them on (what are we missing?)

Ok, Now I have a different issue. I have figured out the potentiometer. But instead of using it to do the lights, I decided to go with it turning on a fan. But now, when I start the code and run the program, its like it interferes with the program I am running and takes over the lights. Code is below. Any reason or thoughts as to why this is happening. I only want the potentiometer to control the fan. Nothing else. Is it the placement of the code?? I am not the best at programming but have to take it for my major.

int numberOfRelays = 8;
int relay[] = {2, 3, 4, 5, 6, 7, 8, 9};
int fan = A0;

#define MAX_CHANNELS 8
 
int ch;
int state;
int chVal[MAX_CHANNELS] = {0};
int pins[] = {2, 3, 4, 5, 6, 7, 8, 9};

enum states
{
  IDLE,
  DELIM,
  READ,
  DISP
};
 
void setup(){
  pinMode(fan, OUTPUT);

  for (ch=0; ch<MAX_CHANNELS; ch++)
  {
    pinMode(pins[ch], OUTPUT);
    digitalWrite(pins[ch], LOW);
   }
  
  state = IDLE;
  ch = 0;
  
  Serial.begin(115200);
}

 
void loop(){

  int pot = analogRead(A1); //pot reads analog input A0 value
  int fan_speed = pot * (255 / 1023.0); //this scales the value between 0-255
  analogWrite(fan,fan_speed); //this sends pwm pulse to pin 9 of fan_speed no
  Serial.println(fan_speed); //this prints fanspeed value in serial
  delay(10); // delay of 10 to provide stability
  
  if (Serial.available())
  {
    switch (state)
    {
      case IDLE:  
        ch = 0;
        if (Serial.read() == '+')
        {
          state = DELIM;          
        }
        else
        {
          state = IDLE;
        }
      break;
        
      case DELIM:
        ch = 0;
        if (Serial.read() == '>')
        {
          state = READ;
        }
        else
        {
          state = IDLE;
        }
      break;
      
      case READ:
        chVal[ch++] = Serial.read();
        if (ch >= MAX_CHANNELS)
        {
          ch = 0;
          state = DISP;
        }
      break; 
      
      case DISP:
        state = IDLE;
        for (ch=0; ch<MAX_CHANNELS; ch++)
        {   
          //analogWrite(pins[ch], chVal[ch]); // Write current values to LED pins  
         
          
          if (chVal[ch] > 0)
          {
            digitalWrite(pins[ch], HIGH);
          }
          else
          {
            digitalWrite(pins[ch], LOW);
          }
          
        }
      break;
    }
  }
}

int fan_speed = pot * (255 / 1023.0);

Watch out for ‘type’ problems in programming.
Try:
long fan_speed = (pot * 255) / 1023;

Also read about ‘map()’.
int fan_speed = map(pot, 0, 1023, 0, 255);

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0

byte fanSpeed = potValue >> 2; // bitshift