Stepper motors are controlled by buttons and limit buttons

Can anyone explain the coding below?

void checkEndstops()
{
  endstop_triggered_x_lower_ = !digitalRead(ENDSTOP_X_LOWER);
  endstop_triggered_x_upper_ = !digitalRead(ENDSTOP_X_UPPER);
  endstop_triggered_y_lower_ = !digitalRead(ENDSTOP_Y_LOWER);
  endstop_triggered_y_upper_ = !digitalRead(ENDSTOP_Y_UPPER);
  endstop_triggered_z_lower_ = !digitalRead(ENDSTOP_Z_LOWER);
  endstop_triggered_z_upper_ = !digitalRead(ENDSTOP_Z_UPPER);

  //assume that positive speeds move the stepper towards the upper endstop
  if (endstop_triggered_x_lower_ && stepper_x.speed() < 0.0f)
    stepper_x.setSpeed(0.0f);
  if (endstop_triggered_x_upper_ && stepper_x.speed() > 0.0f)
    stepper_x.setSpeed(0.0f);

  if (endstop_triggered_y_lower_ && stepper_y.speed() < 0.0f)
    stepper_y.setSpeed(0.0f);
  if (endstop_triggered_y_upper_ && stepper_y.speed() > 0.0f)
    stepper_y.setSpeed(0.0f);

  if (endstop_triggered_z_lower_ && stepper_z.speed() < 0.0f)
    stepper_z.setSpeed(0.0f);
  if (endstop_triggered_z_upper_ && stepper_z.speed() > 0.0f)
    stepper_z.setSpeed(0.0f);

  //homing
  home_triggered_x_ = endstop_triggered_x_lower_;
  home_triggered_y_ = endstop_triggered_y_lower_;
  home_triggered_z_ = endstop_triggered_z_lower_;

  //if the home switch was triggered (or released) just now (home_triggered_x_ is different from home_triggered_x_last_)
  if (home_triggered_x_ ^ home_triggered_x_last_)
  {
    //if the home switch was triggered, reset the stepper position
    if (home_triggered_x_)
      stepper_x.setCurrentPosition(0);    

    //remember the current home switch state 
    home_triggered_x_last_ = home_triggered_x_;
  }  

  //if the home switch was triggered (or released) just now (home_triggered_y_ is different from home_triggered_y_last_)
  if (home_triggered_y_ ^ home_triggered_y_last_)
  {
    //if the home switch was triggered, reset the stepper position
    if (home_triggered_y_)
      stepper_y.setCurrentPosition(0);    

    //remember the current home switch state 
    home_triggered_y_last_ = home_triggered_y_;
  }  

  //if the home switch was triggered (or released) just now (home_triggered_z_ is different from home_triggered_z_last_)
  if (home_triggered_z_ ^ home_triggered_z_last_)
  {
    //if the home switch was triggered, reset the stepper position
    if (home_triggered_z_)
      stepper_z.setCurrentPosition(0);    

    //remember the current home switch state 
    home_triggered_z_last_ = home_triggered_z_;
  }
}

sabar:
Can anyone explain the coding below?

There are lots of comments in the code. What exactly are you having trouble understanding?

And please post the complete program as that provides the context. Add the .ino file as an attachment if it is too long to include in your next Reply.

...R

Stepper motors are controlled by buttons and limit buttons

Please post a link to the "limit buttons" you are using.

I've just about given up on telling people that buttons can't be sewn onto an Arduino (except a lilypad), and accepted the less-than-technically-accurate phrase "button" as a shorthand for "push button switch."

But, only a moron uses "limit button".

But sorry, if you don't know what the code does why are you using it? Where have you found it?