Controlling stepper motors using SPDT toggle

I have picked up an Arduino Uno based project from someone else and I am struggling to understand how the toggle switch works. I have a SPDT toggle switch which I want to use control two stepper motors.

The data sheet for the toggle switch is here:

The motor used is here:

If the switch is in one position I want the motors to perform a function and if the switch is in the other position I want the motors to perform a different function and in the central position I want the motors to not move.
The switch is currently connected so that one terminal of the toggle switch is connected to A5 pin on the Arduino Uno, and the middle terminal is connected to power.
The code used is as follows. I don’t understand how the values are read from the toggle switch, and how you know that when the switch is in the left position the value is less than 20, and in the right position the value is greater than 998. Is my toggle switch connected correctly? Or should I be using digital input?
Many thanks in advance- any help would be appreciated.
The code I’ve been using is below:

#include <Stepper.h>
const int stepsPerRevolution = 100;	
int inPin = A5;                      	// one side of the SPDT switch connected to this                    
Stepper Stepper1(stepsPerRevolution, 8,9,10,11);       
Stepper Stepper2(stepsPerRevolution, 4,5,6,7);          

void setup() {
  Stepper1.setSpeed(30);		//Setting rpm of stepper motors

void loop() {
  int val = analogRead(inPin);
  if (val < 20){					// (if switch is in the left position)
   for(int s=0; s<700; s++){

  if (val > 21 && val < 997){			// (if switch is in the neutral position)

  if (val > 998) {					// (if switch is in the right position)
      for(int s=0; s<1300; s++){		

I’m guessing that there is a resistor connected to the switch (don’t know exactly how) so that in one position the resistance is different from the other position. The analogRead() command reads the voltage on the A5 pin. 0v will give a value of 0 and 5v will give a value of 1023.

This seems a strange arrangement unless all the other pins are used for other purposes. Or maybe the “someone else” did not know that the analog pins can also be used as digital pins.