Jog mode is enabled, in which the Machine can do no other motion control, but can only be controlled using a drop-down switch connected outside the specified footprint.

The Jog mode is divided into the following two control behaviors.

Jog mode – press the switch (pull down) after the start of the movement, until the release (pull up) and then stop.

incJog mode – the switch is moved a unit distance by tapping it, and the distance can be set using setJogOffset().


machine.beginJog(pX, mX, pY, mY, pZ, mZ);
machine.beginJog(pX, mX, pY, mY, pZ, mZ, incJog);


  • machine: for Machine object.
  • pX: Pin pin position corresponding to X-axis positive direction (plus).
  • mX: Pin pin position corresponding to X-axis negative direction (minus).
  • pY: Pin pin position corresponding to the positive direction (plus) of Y-axis.
  • mY: Pin pin position corresponding to the negative direction (minus) of Y-axis.
  • pZ: Pin pin position corresponding to the positive direction (plus) of Z-axis.
  • mZ: Pin pin position corresponding to the Z-axis negative direction (minus).
  • incJog: whether to enable incJog mode, default is false.




Set the basic parameters of the machine and enable the Jog mode to move when the button is triggered.

#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, the motion direction of the motion axis can be reversed.
  // In this example, the direction of x-axis and y-axis should be reversed.
  // 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);
  // The machine must be started before control.
  // Set the machine to jog mode and trigger it with the connected button.
  machine.beginJog(27, 28, 32, 3, 16, 17, false);
  // If the Machine is set to Inc Jog mode, the offset should be configured to set how many millimeters to move with each click.
  // machine.beginJog(27, 28, 32, 3, 16, 17, true);
  // machine.setJogOffset(1.0);
  // Feed speed in Jog mode.
  // Start the stepping motor.
  digitalWrite(EnablePin, LOW);
void loop() {
  Serial.print("Jog position = ");
  Serial.print(", ");
  Serial.print(", ");

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

Your email address will not be published. Required fields are marked *

Scroll to Top