Issues with connecting a slideswitch to change between automatic and manual mode for a fan

// C++ code
//
int switchA = 6;
int Motor = 3; 
int Potentiometer = 1;


void setup()
{
  Serial.begin(9600);// So I can use the serial monitor
  
  //declaring the led outputs
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  
  //declaring the fan motor output
  pinMode(Motor, OUTPUT);
  
  //the temp sensor input
  pinMode(0, INPUT);
  
  //Switch input pin
  pinMode(switchA, INPUT);
  
  //Potentiometer Input pin
  pinMode(Potentiometer, INPUT);
  
  
  Serial.print("voltage:");
  Serial.print("\t");
  Serial.println("deg C:");
  
}

void loop()
{
  Rankleds();//made a seperate function for the leds
  Fanmotor();// This function is for the fan motor
}



void Rankleds()//Void for the leds 
{
  for(int ledpin=10; ledpin<=13; ledpin++)
    /*Used a for loop to make things easier and shorter,
    int ledpin=10 is initialisation
    ledpin<=13 is conditiom
    ledpin++ is increment
    */
  {
    digitalWrite(ledpin, HIGH);//Turn Led ON
    delay(750);// Wait 0.750 seconds
    digitalWrite(ledpin, LOW);// Turn Led OFF
  }
  
  /*
  so a simple explanation: in this for loop,
  it turns on the first led on pin 10 then waits 0.750 seconds
  then turns it off then moves to the next led
  which is on pin 11 and does the same thing until it finishes
  at the led in pin 13, then goes in a loop
  */
}
    

void Fanmotor()
{
  float voltage, degreesC;
  
  voltage = getVoltage();
  degreesC = (voltage - 0.5)*100.0;
  
  
  Serial.print(voltage);
  Serial.print("\t");
  Serial.println(degreesC);
  
  
  delay(1000);
  
  //-------------------
  
  
if (digitalRead(switchA)==HIGH)
{ 
  
   if(degreesC >= 22.0) 
  {
    
      analogWrite(Motor, 255);
      delay(20);
   
  }
  
  else if(degreesC < 22.0)
  {
      analogWrite(Motor, 0);
      delay(20);
  }
     
  
  
}
  else if(digitalRead(switchA) == LOW){
    
  int value = analogRead(Potentiometer);
  float speed1 = (value/1024) * 255;
  analogWrite(3, speed1);
  
  }


 Serial.println(digitalRead(switchA));
    
  //---------------------

}
  
  
  


float getVoltage()
{
  int reading = analogRead(0);
  float voltage = reading * 5.0/1024.0;
  return voltage;
}