Using Serial imput to run a code

First, thanks so much for all the tips!

I changed my code to follow your latest suggestions. Now the code does not actually wait anymore and it wont pause at all.

Here is some code spinets and my full code:

void mandmColor() {
  static byte currentState = MM_SORT;
  switch (currentState) {
    case MM_SORT:
      color();
      printColor();
      findMandmColor();
      startMillis = millis();
      currentState = MM_WAIT;
      break;
    case MM_WAIT:
      if (currentMillis - startMillis <= oneSecond) {
        currentMillis = millis();
        checkButton();
      }
      if else (currentMillis - startMillis > oneSecond) {
        currentState = MM_SORT;
      }
      break;
  }
}
void checkButton() {
  static int lastState =! ISPRESSED;
  int state = readButton();
  if (buttonNewData == NO) {
    if (state != lastState) {
      if (buttonState == ISPRESSED) {
        Serial.println("<Button>");
        if ((toggle == PAUSE) || (toggle == RESTART) || (toggle == SETUP)) {
          toggle = START;
          buttonNewData = YES;
        }
        else if (toggle == START) {
          toggle = PAUSE;
          buttonNewData = YES;
        }
      }
      lastState = state;
    }
  }
}

MM_Sorter_shift_toggle_servo_count11.ino (12 KB)