Problem using "setSpeed" for stepper control

Hi all
I am wanting a stepper motor to 1/2 turn forwards and back again just once when pin3 goes high…
If I use "setSpeed (1000) to control the motor it steps correctly, returns correctly but it ignores the state of pin3 so continually runs the loop.
If I use "setSpeed (motSpeed) the motor doesn`t run at all.
I have enabled the serial monitor and can see that the pin3 status is being reported correctly and I can also see the motSpeed change from 0 to 1000 when pin 3 goes high.

I guess I`m missing something blatantly obvious but I have trolled the net for a day and have drawn a frustrating blank.

I would appreciate knowing where I have gone wrong.

#include <Stepper.h>

#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 32  //2048  

Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);

int  Steps2Take;
int  switchPin = 3;
int  motSpeed; 
void setup()  
{

  Serial.begin (9600);
  pinMode (switchPin, INPUT);
  digitalWrite(switchPin, LOW);
    
  }

void loop()  

{
int pinState = digitalRead(switchPin);
    Serial.print ("Pin Status ");
    Serial.println (pinState);
    delay (1000);
     
    if (pinState == HIGH) { motSpeed = 1000; }
    else { motSpeed = 0; }
    Serial.print ("Motor Speed ");
    Serial.println (motSpeed);
         
      Steps2Take  =  STEPS_PER_OUTPUT_REVOLUTION ;  // Rotate CW 1 turn
  small_stepper.setSpeed(1000);
  small_stepper.step(Steps2Take);
  delay(1000);
  
    Steps2Take  =  - STEPS_PER_OUTPUT_REVOLUTION;  // Rotate CCW 1 turn  
  small_stepper.setSpeed(1000);
  small_stepper.step(Steps2Take);
  delay(1000);


}

well you do

    if (pinState == HIGH) { motSpeed = 1000; }
    else { motSpeed = 0; }

but then superbly ignore motSpeed and do

  small_stepper.setSpeed(1000);

.. so what do you expect... ?

#define STEPS_PER_OUTPUT_REVOLUTION 32 * 32  //2048

32 * 32 = 1024 not 2048.... if you have comments, try to keep them correct..
when you do math in a #define best is to put brackets around the formula to avoid prioritization errors later on. also giving a hint to the compiler of the type can help avoid integer overflow

Speed of the stepper motor is just how fast it will execute a number of steps.

I guess I`m missing something blatantly obvious

Of course you are. It's the same thing you are missing in your other thread on the same damned topic.

Where do you ACTUALLY set the speed of the motor to the value in motSpeed?

Jesus this is a hostile place…“Other Damned Thread”?..forgive me for being new and not realising I had posted twice, I thought the 1st post had been lost in the ether.
I am pleased that when people ask for my advice I am able to reply respectfully.

my understanding is that forums are a place for people to get help and learn not get abuse, derision and disparagement.

In answer to the 1st comment (J-M-L) I explained above what happens when I use both these statements, “setSpeed(motSpeed)” and “setSpeed(1000)” I did this in case it helped with the diagnosis and to show how using 1000 drives the motor and runs the loop but using motSpeed does not.

As for the second unhelpful comment (PaulS) my understanding thus far is that I am setting motSpeed to either 0 or 1000 from my if/else statement:

if (pinState == HIGH) { motSpeed = 1000; }
else { motSpeed = 0; }
Serial.print ("Motor Speed ");
Serial.println (motSpeed);

I then call it from:
Steps2Take = - STEPS_PER_OUTPUT_REVOLUTION; // Rotate CCW 1 turn
small_stepper.setSpeed(motSpeed); //I only left this at 1000 for illustration purposes
small_stepper.step(Steps2Take);
delay(1000);

Please dont feel the need to respond I will be removing my affiliation with this forum.

I will be removing my affiliation with this forum.

You won't be missed.