Set the pin of the hardware limit switch of the machine to define the Home point of the machine.


machine.config_HomePins(xLimit, yLimit, zLimit);


  • machine: is a Machine object.
  • Machine machine(0): There are three groups of Machine 0,1,2 available for use.
  • xLimit, yLimit, zLimit: The pin of the hardware limit switch corresponding to the x, y, and z axes of the machine respectively.


  • true: The setting is successful.
  • false: The setting is wrong, which means the machine does not exist or the setting is done after the machine is started.

Please make sure that the machine exists and make sure that the machine is set up before starting the machine.


Set the basic parameters of the machine and move the machine to the Home point.

#include "Motion86.h"
// Generate machine objects, up to machine 0~2 three machines, each machine has three axes. 
Machine machine(0);
// Stepper motor enable pin.
int EnablePin = 4;
void setup() {
  while (!Serial);
  pinMode(EnablePin, OUTPUT);
  // If necessary, you can reverse the motion direction of the motion axis.
  // PPU (pulse per unit) is a virtual length unit, depending on different requirements.
  // In this example, the unit length of x-axis is set to 80 pulses, which corresponds to 1 mm in real application.
  machine.config_PPU(AXIS_X, 80.0);
  machine.config_PPU(AXIS_Y, 80.0);
  machine.config_PPU(AXIS_Z, 1600.0);
  // Set the software limit for the machine motion.
  machine.config_PosLimit(AXIS_X, 0, 300);
  machine.config_PosLimit(AXIS_Y, 0, 200);
  machine.config_PosLimit(AXIS_Z, 0, 300);
  // Set the pin used to set the limit switch for the home point.
  machine.config_HomePins(2, 7, 8);
  // Before controlling, the machine must be started.
  // Set the default feed rate.
  // Start the software limit.
  // Set the feed rate to return to home.
  machine.setHomeSpeed(1000, 1000, 200);
  // Start the stepper motor.
  digitalWrite(EnablePin, LOW);
  // Return to the home point defined by the limit switch.
home(); }
void loop() {
  // Motion control code...

See also

Libraries Reference Home

The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Leave a Comment

Scroll to Top