user26233: I am trying to write a program to control a stepper, and incorporate a selector switch and a rheostat. 
The object is to make the stepper oscillate, and to be able to control the speed with the rheostat, and the amount of oscillation with the selector switch.
What would the best way to go about this?

user25638: Here are the code fragments that would help you.
Connect the three wires from the potentiometer to your board. The first goes from one of the outer pins of the potentiometerto ground. The second goes from the other outer pin of the potentiometer to 5 volts. The third goes from the middle pin of the potentiometer to the analog pin A0.
Here is the connection schematic:

Here is the code to read the analog value from port A0:
int sensorValue = analogRead(A0);

this would assign a value ranging fro 0-1023 to sensorValue according to the position of the Pot.
int stepsPerRevolution = 200; 
//this variable holds the no of steps the motor rotates to complete a full circle rotation.

int stepCount = 0;  // number of steps the motor has taken

stepsPerRevolution = map(sensorReading, 0, 1023, 0, 200); 

// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);

Here is an example program for controlling the direction of stepper using microswitches:
#define stepPin 2
#define dirPin 3
#define pinLimitswitchLeft 4  // these can be either left or right depending on motor wiring and dir pin.
#define pinLimitswitchRight 5 // these switches must be N.O. types
int stepDelay = 100; // this is the step delay in microseconds. Reduce this to speed up motor rotation and vice versa.

void setup()
{
    pinMode (stepPin, OUTPUT);
    pinMode (dirPin, OUTPUT);
    pinMode (pinLimitswitchLeft, INPUT_PULLUP);
    pinMode (pinLimitswitchRight, INPUT_PULLUP); 
}
    
void loop()
{
    digitalWrite(dirPin, HIGH);  // set direction pin, the direction that the motor will rotate is dictated by it's wiring
    while (digitalRead(pinLimitswitchLeft) == HIGH) // move motor until left limit switch is pressed.
    {
        stepMotor(); 
    }
    
    digitalWrite(dirPin, LOW);  // set direction pin, the direction that the motor will rotate is dictated by it's wiring
    while (digitalRead(pinLimitswitchRight) == HIGH) // move motor until right limit switch is pressed.
    {
        stepMotor(); 
    }
    
}
    
void stepMotor()
{
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(stepDelay);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(stepDelay); 
}

Change the control from the control switch to the number of steps taken by your motor when the switch is pressed and it will work as you require.
I have not included the header files.
Please edit the program as you require

user7508: Majenko provided the correct answer in his comment: you just have to
write a program to do it! This site is not meant to provide you with a
ready made solution, but to give help if you run into an issue while
trying to solve the problem yourself.
That being said, before you attempt to write the program, you should
learn how to interface with the hardware you are using. Here are the
relevant Arduino tutorials:

The Button tutorial is about reading a push button, but you would
do exactly the same to read a switch
Reading a Potentiometer (analog input)
Stepper Speed Control will teach you how to control your
stepper motor

And then there is plenty of material available on the Web for each of
these topics.
Go through the tutorials, understand the programs given as examples,
make them work with your hardware, then put the pieces together to solve
your problem. If you run into an issue you cannot solve buy yourself,
then come back here with a specific question and show us what you have
attempted so far, including code and schematic. See also How do I ask
a good question?.

26233: <p>I am trying to write a program to control a stepper, and incorporate a selector switch and a rheostat. </p>

<p>The object is to make the stepper oscillate, and to be able to control the speed with the rheostat, and the amount of oscillation with the selector switch.</p>

<p>What would the best way to go about this?</p>
 25638: <p>Here are the code fragments that would help you.</p>
<p>Connect the three wires from the potentiometer to your board. The first goes from one of the outer pins of the potentiometerto ground. The second goes from the other outer pin of the potentiometer to 5 volts. The third goes from the middle pin of the potentiometer to the analog pin <code>A0</code>.</p>
<p><strong>Here is the connection schematic:</strong></p>
<p><a href="https://i.stack.imgur.com/dlY5g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dlY5g.png" alt="enter image description here" /></a></p>
<p>Here is the code to read the analog value from port A0:</p>
<pre class="lang-cpp prettyprint-override"><code>int sensorValue = analogRead(A0);
</code></pre>
<p>this would assign a value ranging fro 0-1023 to <code>sensorValue</code> according to the position of the Pot.</p>
<pre class="lang-cpp prettyprint-override"><code>int stepsPerRevolution = 200; 
//this variable holds the no of steps the motor rotates to complete a full circle rotation.

int stepCount = 0;  // number of steps the motor has taken

stepsPerRevolution = map(sensorReading, 0, 1023, 0, 200); 

// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);
</code></pre>
<p><strong>Here is an example program for controlling the direction of stepper using microswitches:</strong></p>
<pre class="lang-cpp prettyprint-override"><code>#define stepPin 2
#define dirPin 3
#define pinLimitswitchLeft 4  // these can be either left or right depending on motor wiring and dir pin.
#define pinLimitswitchRight 5 // these switches must be N.O. types
int stepDelay = 100; // this is the step delay in microseconds. Reduce this to speed up motor rotation and vice versa.

void setup()
{
    pinMode (stepPin, OUTPUT);
    pinMode (dirPin, OUTPUT);
    pinMode (pinLimitswitchLeft, INPUT_PULLUP);
    pinMode (pinLimitswitchRight, INPUT_PULLUP); 
}
    
void loop()
{
    digitalWrite(dirPin, HIGH);  // set direction pin, the direction that the motor will rotate is dictated by it's wiring
    while (digitalRead(pinLimitswitchLeft) == HIGH) // move motor until left limit switch is pressed.
    {
        stepMotor(); 
    }
    
    digitalWrite(dirPin, LOW);  // set direction pin, the direction that the motor will rotate is dictated by it's wiring
    while (digitalRead(pinLimitswitchRight) == HIGH) // move motor until right limit switch is pressed.
    {
        stepMotor(); 
    }
    
}
    
void stepMotor()
{
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(stepDelay);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(stepDelay); 
}
</code></pre>
<p>Change the control from the control switch to the number of steps taken by your motor when the switch is pressed and it will work as you require.</p>
<p><strong>I have not included the header files.</strong></p>
<p>Please edit the program as you require</p>
 7508: <p>Majenko provided the correct answer in his comment: you just have to
write a program to do it! This site is not meant to provide you with a
ready made solution, but to give help if you run into an issue while
trying to <em>solve the problem yourself</em>.</p>

<p>That being said, before you attempt to write the program, you should
learn how to interface with the hardware you are using. Here are the
relevant Arduino tutorials:</p>

<ul>
<li>The <a href="https://www.arduino.cc/en/Tutorial/Button" rel="nofollow noreferrer">Button</a> tutorial is about reading a push button, but you would
do exactly the same to read a switch</li>
<li><a href="https://www.arduino.cc/en/tutorial/potentiometer" rel="nofollow noreferrer">Reading a Potentiometer (analog input)</a></li>
<li><a href="https://www.arduino.cc/en/Tutorial/StepperSpeedControl" rel="nofollow noreferrer">Stepper Speed Control</a> will teach you how to control your
stepper motor</li>
</ul>

<p>And then there is plenty of material available on the Web for each of
these topics.</p>

<p>Go through the tutorials, understand the programs given as examples,
make them work with your hardware, then put the pieces together to solve
your problem. If you run into an issue you cannot solve buy yourself,
then come back here with a <em>specific</em> question and show us what you have
attempted so far, including code and schematic. See also <a href="https://arduino.stackexchange.com/help/how-to-ask">How do I ask
a good question?</a>.</p>
