Driving stepper for specific steps but other button inputs ignored

I just started to use the Arduino so please be patient. I'm working on setting up a system that when a button is pushed it drives a stepper motor 180 degrees then stops. At the same time I have the possibility of another switch being activated for a counter to an LCD screen. All parts work individually as they should and together until during the stepper motor running the other switch will not be read. I've tried looking for how to run the stepper in the "background" while still looking for inputs to no avail.

/*
   Reloading station
   Operations
   1) Power case feeder using light sensor as input to run motor or not.
   2) Rotate case to position from button push
   3) Count rounds as they are completed
      1) have reset count button
      2) have +1 and -1 buttons for counter
*/

#include <Stepper.h>                  // Stepper Library
#include <LiquidCrystal.h>            // LCD Library

// Stepper Motor variables for speed and steps per revolution
const int stepsPerRevolution = 2048;  // change this to fit the number of steps per revolution
const int rolePerMinute = 17;         // Adjustable range of 28BYJ-48 stepper is 0~17 rpm

Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);     // initialize the stepper library on pins 8 through 11:
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);     // initialize the library with the numbers of the interface pins
// Variables for wait before accepting new input
const unsigned long eventtime_1_count = 250; // 250 milliseconds
const unsigned long eventtime_2_reset = 500; //500 miliseconds

//Delay function based off millis.
unsigned long previoustime_1 = 0;
unsigned long previoustime_2 = 0;
unsigned long currenttime;

const int button = 13;                // Set input to pin 13
int lastState = HIGH;                 // Set Buttons last state to HIGH (not pressed)
int currState;                        // Declare currState
const int sensor = 12;                // Declare Sensor and set pin to 12
int count = 0;                        // Declare count for rounds and set to 0
const int reset = 22;                 // Declare reset button pin to 22


void setup() 
{ 
  Serial.begin(9600);
  myStepper.setSpeed(rolePerMinute); //set speed of stepper
  pinMode(button, INPUT_PULLUP);     //set input pin to internal resistor (high = open switch, low = closed switch)
  pinMode(sensor, INPUT_PULLUP);     //set input pin to internal resistor (high = open switch, low = closed switch)
  pinMode(reset, INPUT_PULLUP);      //set input pin to internal resistor (high = open switch, low = closed switch)
  lcd.begin(16, 2);                  // set up the LCD's number of columns and rows:      
  lcd.print("Rounds = 0");           // Print a message to the LCD.
 
}

void loop() 
{
  currenttime = millis();  //read current time
  CaseMotorFunction();     //jump to case motor function
  RoundCountFunction();
  RoundCountResetFunction();
}

void CaseMotorFunction()
{
  currState = digitalRead(button);
  if (currState == LOW && currState != lastState)
  {
     Serial.println("clockwise");                       // rotate motor clockwise
     myStepper.step(stepsPerRevolution / 2);            // rotate motor 180 degrees                                     
     lastState = button;                                // change last state to current state
  } 
  lastState = currState;
}
void RoundCountFunction()
{
  // check if enough time has passed since previous activation (using as a debounce/double click)
  if (currenttime - previoustime_1 >= eventtime_1_count)
  {
    // if switch is pressed add 1 to counter
    if (digitalRead(sensor) == LOW)
    {
      // increase counter
      count = count + 1;
      // set the cursor to column 0, line 1
      lcd.setCursor(9, 0);
      // print the number of rounds
      lcd.print(count);
      // update previoustime millis
      previoustime_1 = currenttime;
   }
  }
}
void RoundCountResetFunction()
{
  // check if enough time has passed since previous activation (using as a debounce/double click)
  if (currenttime - previoustime_2 >= eventtime_2_reset)
  {
    // if switch is pressed reset counter to 0
    if (digitalRead(reset) == LOW)
    {
      // set count int to "0"
      count = 0;
      // sets position of cursor on LCD
      lcd.setCursor(9, 0);
      // print "0     " to LCD
      lcd.print("0    ");
      // change millis previous time
      previoustime_2 = currenttime;
    }
  }
}

     lastState = button;                                // change last state to current state
  } 
  lastState = currState;

The first line sets lastState to the pin number for the button, which is then immediately overwritten. Rethink this bit of code.

For background stepping, consider the AccelStepper library. It is far more sophisticated.

good catch I'll fix that, but I don't believe that is my problem for having it not process the "RoundCountFunction()" while the stepper is being driven.

I did read some on AccelStepper so I'll look into that more.

The AccelStepper library doesn't step in the background. You have to continuously call .run() [or similar] functions for it to actually do the stepping.

If you want to control a stepper in the background using timers, look at the MobaTools library which really does things in the background using timer interrupts.

That is exactly your problem. The step() function is blocking.

Stepper - step()

This function turns the motor a specific number of steps, at a speed determined by the most recent call to setSpeed(). This function is blocking; that is, it will wait until the motor has finished moving to pass control to the next line in your sketch. For example, if you set the speed to, say, 1 RPM and called step(100) on a 100-step motor, this function would take a full minute to run. For better control, keep the speed high and only go a few steps with each call to step().

I disagree. Calling run() does not take up a significant amount of foreground code or time, nor do most API functions block or delay.

Yea I understand the Step Function is blocking. I was saying the double code inside that wasn't the reason. I'll look into how to call to step smaller step amounts, but I believe the AccelStepper has the run() which can do this I think as I'm reading.

I'll lookinto the MobaTools thanks for the suggestions. I've been looking at the AccelSepper and I think the run() might do what I want.

I would agree is does not take up much foreground code.

I guess we disagree on what "background" means. To me, that means not having to regularly call a function to cause action v. having interrupts do things outside your normal code.

Either way, moving to the AccelStepper or MobaTools library will greatly simplify the code.

Here's a MobaTools built-in example implemented in Wokwi that drives a stepper for specific steps while not ignoring other inputs: