I would you like to process at the moment when press Buttons

Hey everyone,
I created a System. This System has got Step Motor and Led. I added buttons with Processing on System but I want to use together all Buttons on System. My problem is here. I am pressing button. It is working. Okay! but I pressed other Buttons but not working at the moment. Other buttons are waiting end of process. I added look like “START” and “STOP” Buttons. If I pressed “START” button, I can’t stop processing. I must wait end of the process. I don’t want to wait. I would you like to process at the moment when press Buttons. I need help for this topic. What should I do? I hope so You can help me. I am sharing codes under this topic. Thanks for reading…
ARDUINO CODES>

int dirPin = 2;
int stepPin = 3;
int ledPin = 4;
int incomingByte = 0;
int stepsPerRevolution = 400;

void setup() {

  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(ledPin, OUTPUT);

  Serial.begin(9600);
  Serial.println("Press 7 to ↓50");
  Serial.println("Press 6 to ↑50");
  Serial.println("Press 5 to GO HOME");
  Serial.println("Press 4 to LED OFF");
  Serial.println("Press 3 to LED ON");
  Serial.println("Press 2 to StepMotor STOP");
  Serial.println("Press 1 to StepMotor >");
  Serial.println("Press 0 to StepMotor <");
}

void loop() {
      if (Serial.available() > 0) {
       }
        incomingByte = Serial.read();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      
              if(incomingByte == '7'){

            digitalWrite(dirPin, LOW);
          
            for (int i = 0; i < 0.5*stepsPerRevolution; i++) {
              
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(0);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(0);
    
            Serial.println("↑50");
            }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      
       }else if(incomingByte == '6'){

            digitalWrite(dirPin, HIGH);
          
            for (int i = 0; i < 0.5*stepsPerRevolution; i++) {
              
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(0);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(0);
    
            Serial.println("↑50");
            }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
       }else if(incomingByte == '5'){
           
            digitalWrite(dirPin, LOW);
          
            for (int i = 4; i < 4*stepsPerRevolution; i++) {
              
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(0);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(0);
    
           Serial.println("GO HOME");
        }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
  
        }else if(incomingByte == '4'){
           digitalWrite(ledPin, LOW);
           Serial.println("LED OFF");
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
        if(incomingByte == '3'){
           digitalWrite(ledPin, HIGH);
           Serial.println("LED ON");
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      
        if(incomingByte == '2'){
           Serial.end();
           Serial.println("StepMotor STOP");
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
        if(incomingByte == '1'){
            digitalWrite(dirPin, HIGH);
          
            for (int i = 0; i < 1*stepsPerRevolution; i++) {
              
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(0);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(0);
    
            Serial.println("StepMotor >");
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      
        }else if(incomingByte == '0'){

            digitalWrite(dirPin, LOW);
          
            for (int i = 0; i < 1*stepsPerRevolution; i++) {
              
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(0);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(0);
    
            Serial.println("StepMotor <");
            }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        }
      }

I can't stop processing. I must wait end of the process. I don't want to wait. I would you like to process at the moment when press Buttons.

You need to rewrite your code as a state machine. Most of the time it is because of using the delay function. I don't see this in your code but I do see a very big for loop. This needs unraveling which means do one iteration of the loop and then check the buttons, then do another iteration of the loop and check again.

So replace the for loop instruction with variables that hold the loop index.

See my
http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html
Or Robin2's several things at once
http://forum.arduino.cc/index.php?topic=223286.0

I'm confused by your use of Processing with capital-P:

I added buttons with Processing on System

.... and processing with small-P:

I can't stop processing

Does Processing on System refer to a processing.org application on your PC, and I can't stop processing refer to the sketch on the Arduino?