Get voltage of pin

So I'm attempting to get a voltage of a few pins that LED's are connected to in order to determine if the LEDs are ON or OFF. I have created a function to do this, but all I am getting is 'X' which is the NOT USED flag in my program.

I am simulating toggle switches (6) via code, hooked up to pins 2,3,5,6,7,8 of the Arduino UNO. These pins are hooked to a GAL IC (inputs) and I need to know if the LED's from the outputs are engaged or not in order to decode the logic since the GAL is locked.

The code initializes the output LEDs to ensure they are ON with a digitalWrite LOW command on each output pin.

The code then pulls in a text file from a SD Card line by line that has 6 characters per line (a's and b's). a=low to ground and b=high to +5v. Processes the line by line to put the 6 character strings into an array. (format: aabbab) It's a permutation of all possible switch configurations.

Now it needs to check the voltage to determine if the LED is ON or OFF.

I am first pulling the current voltage into a variable (v1, v2, v3, v4) from the different pins (A0,A1,A2,A3), these are actually hooked up to the GAL outputs as these engage or disengage the LEDs based on the switch position.

Once I have the current voltage then I am running IF statements to assign either L for LOW, H for HIGH and X for NOT USED.

I get all X's.. and the formatting is off.

My output should look like:

SW1 SW2 SW3 SW4 SW5 SW6 (this is a Serial.println at the beginning of the void setup
X L H X X X (this should print based on the correct assignment)

My code is below and if there is a better way to do it then I'm all ears!

#include <SD.h>
#include <SPI.h>

//LED LOW status = LED is ON
//LED HIGH status = LED is OFF

File printFile;
String buffer;
boolean SDfound;
const int sw1pin = 2;
const int sw2pin = 3;
const int sw3pin = 5;
const int sw4pin = 6;
const int sw5pin = 7;
const int sw6pin = 8;
char switchcombo[7];
char sw1,sw2,sw3,sw4,sw5,sw6;
int v1,v2,v3,v4;

void setup() {
  //pin mode setup
  pinMode(sw1pin, OUTPUT);
  pinMode(sw2pin, OUTPUT);
  pinMode(sw3pin, OUTPUT);
  pinMode(sw4pin, OUTPUT);
  pinMode(sw5pin, OUTPUT);
  pinMode(sw6pin, OUTPUT);

  digitalWrite(sw1pin,LOW);
  digitalWrite(sw2pin,LOW);
  digitalWrite(sw3pin,LOW);
  digitalWrite(sw4pin,LOW);
  digitalWrite(sw5pin,LOW);
  digitalWrite(sw6pin,LOW);
  //end pin mode setup
  
  Serial.begin(9600); //open serial port 
  

  //Initialize SD card and open file
  Serial.println("Initializing SD card..."); 
  if (SDfound == 0) {
    if (!SD.begin(4)) {
      Serial.println("The SD card cannot be found...");
      while(1);
    }
    Serial.println("SD card found!");
  }
  SDfound = 1;
  printFile = SD.open("switch.txt");

  if (!printFile) {
    Serial.print("The text file cannot be opened");
    while(1);
  }

  Serial.println("Switch Legend:");
  Serial.println("X = NOT USED");
  Serial.println("L = LOW TO GND");
  Serial.println("H = HIGH TO +5V");
  Serial.println("  SW1  SW2  SW3  SW4  SW5  SW6");
  
  while (printFile.available()) {
    buffer = printFile.readStringUntil('\n');
    //Serial.println(buffer); //Printing for debugging purpose  
    buffer.toCharArray(switchcombo, 7);   

  execswcombo();
    
  }

  printFile.close();
}

void loop() {
//empty
}

void readvoltage(){
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  int sensorValue1 = analogRead(A0);
  v1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);
  v2 = analogRead(A1);
  int sensorValue3 = analogRead(A2);
  v3 = analogRead(A2);
  v4 = analogRead(A3);
  
  float voltage1 = sensorValue1 * (5.0 / 1023.0);
  if (voltage1 = v1){
    Serial.print("  X");
  }else if(voltage1 != v1 || voltage1 < 4.5) {
    Serial.print("  H");
  }else if (voltage1 != v1 || voltage1 > 4.5){
    Serial.print("  L");
  }
  float voltage2 = sensorValue2 * (5.0 / 1023.0);
  if (voltage2 = v2){
    Serial.print("  X");
  }else if(voltage2 != v2 || voltage2 < 4.5) {
    Serial.print("  H");
  }else if (voltage2 != v2 || voltage2 > 4.5){
    Serial.print("  L");
  }

  float voltage3 = sensorValue3 * (5.0 / 1023.0);
  if (voltage3 = v3){
    Serial.print("  X");
  }else if(voltage3 != v3 || voltage3 < 4.5) {
    Serial.print("  H");
  }else if (voltage3 != v3 || voltage3 > 4.5){
    Serial.print("  L");
  }

  float voltage4 = sensorValue3 * (5.0 / 1023.0);
  if (voltage4 = v4){
    Serial.print("  X");
  }else if(voltage4 != v4 || voltage4 < 4.5) {
    Serial.print("  H");
  }else if (voltage4 != v4 || voltage4 > 4.5){
    Serial.print("  L");
  }
  // print out the value you read:
}

void execswcombo(){
  
  if(switchcombo[0] == 'a'){
    digitalWrite(sw1pin,HIGH);
    readvoltage();
  }else{
    digitalWrite(sw1pin,LOW);
    readvoltage();
  }
  
  if(switchcombo[1] == 'a'){
    digitalWrite(sw2pin,HIGH);
    readvoltage();
  }else{
    digitalWrite(sw2pin,LOW);
    readvoltage();
  }

  if(switchcombo[2] == "a"){
    digitalWrite(sw3pin,HIGH);
    readvoltage();
  }else{
    digitalWrite(sw3pin,LOW);
    readvoltage();
  }

  if(switchcombo[3] == 'a'){
    digitalWrite(sw4pin,HIGH);
    readvoltage();
  }else{
    digitalWrite(sw4pin,LOW);
    readvoltage();
  }

  if(switchcombo[4] == 'a'){
    digitalWrite(sw5pin,HIGH);
    readvoltage();
  }else{
    digitalWrite(sw5pin,LOW);
    readvoltage();
  }

  if(switchcombo[5] == 'a'){
    digitalWrite(sw6pin,HIGH);
    readvoltage();
    Serial.println();
  }else{
    digitalWrite(sw6pin,LOW);
    readvoltage();
    Serial.println();
  }
}

When the code runs the output generates looks like:

23:53:16.148 ->   SW1  SW2  SW3  SW4  SW5  SW6
23:53:16.148 ->   X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
23:53:16.241 ->   X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
23:53:16.335 ->   X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
23:53:16.381 ->   X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X
23:53:16.475 ->   X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X

any help is appreciated.

OOPS
if (voltage1 = v1)
= IS NOT THE SAME AS ==


Show us a good schematic of your proposed circuit. Show us a good image of your ‘actual’ wiring.
Give links to components.

Once you've fixed that , in the else clause you know voltage1 is NOT equal to v1 (otherwise you would not enter the else clause), so there is no need to test for that

  if (voltage1 == v1){
    Serial.print("  X");
  }else if(voltage1 < 4.5) {
    Serial.print("  H");
  }else if (voltage1 > 4.5){
    Serial.print("  L");
  }

last, what happens is voltage is exactly 4.5 ?

and same applies for v2

That is roughly the same as saying:
if (v2 * (5.0/1023.0) == v2)
It is only ever true if v2 == 0.

Some notes -

What are the actual voltages when the LEDs are on & off? Since these are digital signals you may not need to read the analog voltage.

with digital inputs the Arduino reads 1.5V or less (0.3Vcc) as low and anything 3V or more (0.6Vcc) as high. (In-between is undefined and might read high or low.)

If you use integers for voltage you can't get 4.5V. Integers don't have decimals and they are NOT automatically rounded. They are truncated. If the "calculated" value is 4.99 the integer value is 4.

It's OK for your code to calculate voltage but it's not necessary... For example, if 5V is 1023 then 4.5V is 921.

In general, you rarely expect an exact analog value. You normally look for less-than, or greater-than, or a range of values.

With this GAL when the LEDs are OFF it reads 5.0v, i have seen it as low as 4.98v. When the LED is ON it ranges from 2.48 to 2.6v