using two buttons to control 1 motor

I am looking to have a stepper motor spin at a constant rate unless I press (and hold down) 1 of 2 buttons. One to make it go slower and one to make it go faster.

I have confirmed that both buttons do work by writing a sketch that only looks for one button.

I am just not sure how the if/else lines are logically read. This seems right but only the RA_buttonFast button works.

#include <AccelStepper.h>

int RAmotorSpeed = 1000; // steps per second
int DecMotorSpeed = 500;
int half_RAspeed = 500;
int double_RAspeed = 2000;
int MaxSpeed = 10000;

int RADirPin = 12; //digital pin 12
int RAStepPin = 11; //digital pin 11
int EN_PIN_RA = 10; //enable (CFG6)

int EN_PIN_dec = 7; //enable dec cfg6
int DecDir = 9; //dec direction pin
int DecStep = 8; //dec step pin

const int RA_buttonSlow = 14; // the number of the pushbutton pin
const int RA_buttonFast = 15;
int RA_Slow_buttonState = 0; // variable for reading the pushbutton status
int RA_fast_buttonState = 0;

//set up the accelStepper intance
//the “1” tells it we are using a driver

AccelStepper stepperRA(1, RAStepPin, RADirPin);
AccelStepper stepperDec(1, DecStep, DecDir);

void setup()
{
stepperRA.setMaxSpeed(MaxSpeed);
stepperRA.setSpeed(RAmotorSpeed);
stepperDec.setMaxSpeed(MaxSpeed);
stepperDec.setSpeed(DecMotorSpeed);
pinMode(RA_buttonSlow, INPUT);
pinMode(RA_buttonFast, INPUT);

}

void loop()
{
stepperRA.runSpeed();
stepperDec.runSpeed();

// read the state of the pushbutton value:
RA_Slow_buttonState = digitalRead(RA_buttonSlow);
RA_fast_buttonState = digitalRead(RA_buttonFast);

// check if the pushbutton is pressed. If it is, the buttonState is LOW

if (RA_Slow_buttonState == LOW) { // make motor turn half as fast
stepperRA.setSpeed(half_RAspeed);
}

else if (RA_Slow_buttonState == HIGH) { // return to normal speed
stepperRA.setSpeed(RAmotorSpeed);
}

if (RA_fast_buttonState == LOW){ // make motor turn 2x fast
stepperRA.setSpeed(double_RAspeed);

}
else if (RA_fast_buttonState == HIGH){ // return to normal speed
stepperRA.setSpeed(RAmotorSpeed);
}
}

solved:

#include <AccelStepper.h>

int RAmotorSpeed = 1000; // steps per second
int DecMotorSpeed = 500;
int half_RAspeed = 500;
int double_RAspeed = 2000;
int MaxSpeed = 10000;

int RADirPin = 12; //digital pin 12
int RAStepPin = 11; //digital pin 11
int EN_PIN_RA = 10; //enable (CFG6)

int EN_PIN_dec = 7; //enable dec cfg6
int DecDir = 9; //dec direction pin
int DecStep = 8; //dec step pin

const int RA_buttonSlow = 14; // the number of the pushbutton pin
const int RA_buttonFast = 15;
int RA_Slow_buttonState = 0; // variable for reading the pushbutton status
int RA_fast_buttonState = 0;

//set up the accelStepper intance
//the “1” tells it we are using a driver

AccelStepper stepperRA(1, RAStepPin, RADirPin);
AccelStepper stepperDec(1, DecStep, DecDir);

void setup()
{
stepperRA.setMaxSpeed(MaxSpeed);
stepperRA.setSpeed(RAmotorSpeed);
stepperDec.setMaxSpeed(MaxSpeed);
stepperDec.setSpeed(DecMotorSpeed);
pinMode(RA_buttonSlow, INPUT);
pinMode(RA_buttonFast, INPUT);

}

void loop()
{
stepperRA.runSpeed();
stepperDec.runSpeed();

// read the state of the pushbutton value:
RA_Slow_buttonState = digitalRead(RA_buttonSlow);
RA_fast_buttonState = digitalRead(RA_buttonFast);

// check if the pushbutton is pressed. If it is, the buttonState is LOW

if (RA_Slow_buttonState == LOW) { // make motor turn half as fast
stepperRA.setSpeed(half_RAspeed);
}

else if (RA_fast_buttonState == LOW){ // make motor turn 2x fast
stepperRA.setSpeed(double_RAspeed);

}
else { // return to normal speed
stepperRA.setSpeed(RAmotorSpeed);
}
}

So, every time through loop() that sees that the appropriate switch is pressed, double or halve the speed of the motor. Good thing volume controls don't work that way.