Linear motion at feed rate to the target point.

Please refer to the motion method explanation page for more information on the various motion methods.


machine.line(x, y, z);
machine.line(x, y, z, feedrate);


  • machine: Machine object.
  • x: Target X coordinates.
  • y: Target Y coordinates.
  • z: Target Z coordinates.
  • feedrate: Feed rate, the last recorded feed rate will be used when no parameter is passed.



  • true: The machine exists and was created successfully.
  • false: The machine does not exist or failed to create.


Set the basic parameters of the machine and move the machine back and forth in a straight line to (10, 10, 10).

#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.
  // Start the stepper motor.
  digitalWrite(EnablePin, LOW);
void loop() {
  // Linear motion to (10, 10, 10).
  machine.line(10, 10, 10);
  // Linear motion to (0, 0, 0).
  machine.line(0, 0, 0);
  // Wait until the planned motion is completed.
  while (machine.isMoving());

Translated with (free version)

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