getting the loop to pause

In the code provided when I’ve finished making the functions I would like to pause the main loop while I wait for the loop to finish the function that it is currently on.

#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Stepper.h>

#define STEPS 200
#define ledRed 8
#define ledGreen 9
#define input1 52
#define input2 53

const int numRows = 2;
const int numCols = 16;
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};
byte rowPins[ROWS] = { 40, 50, 48, 44 };
byte colPins[COLS] = { 42, 38, 46 };

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal lcd( 12, 11, 5, 4, 3, 2 );
Stepper stepper(STEPS, 36, 34, 32, 30);
Stepper stepper2(STEPS, 28, 26, 24, 22);

int bays = 10;
int steps = 0;

void setup()
{
  pinMode(input1, INPUT);
  pinMode(input2, INPUT);
  pinMode(ledRed, OUTPUT);
  pinMode(ledGreen, OUTPUT);
  lcd.begin(numCols, numRows);
  lcd.print("Welcome");
  lcd.setCursor(0, 1);
  stepper.setSpeed(30);
}

void loop()
{
  lcdin()
//pause the system
  bays = opengate(bays)
}

int opengate(int i)
{
  int val = digitalRead(input1);
  if (val == LOW)
  {
    delay(20000);
    steps = 50;
    stepper.step(steps);
    delay(10000);
    steps = -50;
    stepper.step(steps);
    delay(1000);
  }
  i = i - 1;
  return i;
}

int closegate(int i)
{
  int val = digitalRead(input2);
  if (val == LOW)
  {
    steps = 50;
    stepper2.step(steps);
    delay(10000);
    steps = -50;
    stepper2.step(steps);
    delay(1000);
  }
  i = i + 1;
  return i;
}

int ledlight(int i)
{
  if (i >= 1)
  {
    digitalWrite(ledGreen, HIGH);
    lcd.clear();
    lcd.print("Input passcode:");
    lcd.setCursor(0, 1);
  }
  else
  {
    digitalWrite(ledRed, HIGH);
    lcd.clear();
    lcd.print("No spots left");
    lcd.setCursor(0, 1);
  }
}

int lcdin()
{
  char key = kpd.getKey();
  if (key)
  {
    switch (key)
    {
      case '#':
        lcd.clear();
        lcd.print("Input passcode:");
        lcd.setCursor(0, 1);
        break;
      default:
        lcd.print(key);
    }
  }
}

int lcdout()
{
  char key = kpd.getKey();
  if (key)
  {
    switch (key)
    {
      case '#':
        lcd.clear();
        lcd.print("Thx for coming");
        delay(5000);
        lcd.clear();
        lcd.print("Input passcode:");
        lcd.setCursor(0, 1);
        break;
      default:
        lcd.print(key);
    }
  }
}

the loop to finish the function that it is currently on.

When a function s called it runs not loop. loop does not do other tings while the function is running.

Mark

Calling a function from anywhere passes control to that function and the code that called the function is stopped at the function call until the called function returns control to the calling function.

"getting the loop to pause", is poor thinking for a microcontroller.

What your really need to be think, is that the loop keeps running, but just doesn't do anything.