Arduino UNO Setpoint Troubleshooting

My original post was removed. I'm sorry I'm not as familiar with the posting requirements. I really need help with this and I can't find the original answers y'all provided. I'm trying to get my inputs and outputs coordinated so that when A0 sees a voltage above the setpoint, the outputs associated go high. I'm trying to figure out which portion of code should go where. Please let me know what I can do to improve this. Thanks!


// Voltage Input to Arduino
const int analogInPin1 = A0;   
const int analogInPin2 = A1;
const int analogInPin3 = A2;
const int analogInPin4 = A3;
const int analogInPin5 = A4;
const int analogInPin6 = A5;

// Assigning the Ouputs to the Relays
const int R1 = 0;         // Relay 1 
const int R2 = 1;         // Relay 2
const int R3 = 2;         // Relay 3
const int R4 = 3;         // Relay 4
const int R5 = 4;         // Relay 5
const int R6 = 5;         // Relay 6
const int R7 = 6;         // Relay 7
const int R8 = 7;         // Relay 8
const int R9 = 8;         // Relay 9
const int R10 = 9;        // Relay 10
const int R11 = 10;       // Relay 11
const int R12 = 11;       // Relay 12

// Initial States of Inputs/Outputs & Establishing the SetPoint
int sensorValue1 = 0;         // Value Read From Input A0
int sensorValue2 = 0;         // Value Read From Input A1
int sensorValue3 = 0;         // Value Read From Input A2
int sensorValue4 = 0;         // Value Read From Input A3
int sensorValue5 = 0;         // Value Read From Input A4
int sensorValue6 = 0;         // Value Read From Input A5

int setPoint = 300;           // Initial value of setPoint

int R1State = 0;              // Store State of Relay 1
int R2State = 0;              // Store State of Relay 2
int R3State = 0;              // Store State of Relay 3
int R4State = 0;              // Store State of Relay 4
int R5State = 0;              // Store State of Relay 5
int R6State = 0;              // Store State of Relay 6
int R7State = 0;              // Store State of Relay 7
int R8State = 0;              // Store State of Relay 8
int R9State = 0;              // Store State of Relay 9
int R10State = 0;             // Store State of Relay 10
int R11State = 0;             // Store State of Relay 11
int R12State = 0;             // Store State of Relay 12

int voltage = 0;

void setup() {
  // configure hardware
  pinMode(R1, OUTPUT);      // Set Relay 1 as an Output
  pinMode(R2, OUTPUT);      // Set Relay 2 as an Output
  pinMode(R3, OUTPUT);      // Set Relay 3 as an Output
  pinMode(R4, OUTPUT);      // Set Relay 4 as an Output
  pinMode(R5, OUTPUT);      // Set Relay 5 as an Output
  pinMode(R6, OUTPUT);      // Set Relay 6 as an Output
  pinMode(R7, OUTPUT);      // Set Relay 7 as an Output
  pinMode(R8, OUTPUT);      // Set Relay 8 as an Output
  pinMode(R9, OUTPUT);      // Set Relay 9 as an Output
  pinMode(R10, OUTPUT);     // Set Relay 10 as an Output
  pinMode(R11, OUTPUT);     // Set Relay 11 as an Output
  pinMode(R12, OUTPUT);     // Set Relay 12 as an Output

    // read the analog in value
  sensorValue1 = analogRead(analogInPin1);
  voltage = sensorValue1 * 5.0/1023;  
  sensorValue2 = analogRead(analogInPin2);
  sensorValue3 = analogRead(analogInPin3);
  sensorValue4 = analogRead(analogInPin4);
  sensorValue5 = analogRead(analogInPin5); 
  sensorValue6 = analogRead(analogInPin6);
}

void loop() {

  // Check Voltage Level For Relays 1 & 2
  if (sensorValue1 > setPoint)
    R1State = 1;   
  else
    R1State = 0;
  
  if (sensorValue1 > setPoint)
  R2State = 1;
  else
  R2State = 0;


  // Check Voltage Level for Relays 3 & 4
  if (sensorValue2 > setPoint)
  R3State = 1;
  else
  R3State = 0;
  
  if (sensorValue2 > setPoint)
  R4State = 1;
  else
  R4State = 0;

  // Check Voltage Levels for Relays 5 & 6
  if (sensorValue3 > setPoint)
  R5State = 1;
  else
  R5State = 0;

  if (sensorValue3 > setPoint)
  R6State = 1;
  else
  R6State = 0;
  
  // Check Voltage Levels for Relays 7 & 8
  if (sensorValue4 > setPoint)
  R7State = 1;
  else
  R7State = 0;

  if (sensorValue4 > setPoint)
  R8State = 1;
  else
  R8State = 0;

  // Check Voltage Levels for Relays 9 & 10 (SECONDARY)
  if (sensorValue5 > setPoint)
  R9State = 1;
  else
  R9State = 0;

  if (sensorValue5 > setPoint)
  R10State = 1;
  else
  R10State = 0;

  // Check Voltage Levels for Relays 11 & 12 (SECONDARY)
  if (sensorValue6 > setPoint)
  R11State = 1;
  else
  R11State = 0;

  if (sensorValue6 > setPoint)
  R11State = 1;
  else
  R11State = 0;

  // wait 100 milliseconds before the next loop
  delay(1000);                     
}

You have a lot of.repeated code, but nothing seems to do anything except set variables.

I suggest that you try and get it working for one input and its corresponding output to start with.

Your analogReads need to live in loop, not setup.

You need a line of code to set the state of each relay, also in loop.

I am not sure why it was deleted but I have undeleted it Arduino UNO Setpoint Issue so I am going to lock this one