Arduino_EMBRYO_2 - getPosition()

Returns the current position of the robot carriage in centimeters.

Syntax

axis.getPosition()

Returns

The current distance in centimeters from motor home position.

Example

#include <Arduino_EMBRYO_2.h>

StepMotor axis(1, A5, 5, 6, 3, 4, A2, A1, 2, 12);

void setup() {
  Serial.begin(9600);
  while (!Serial) {};
  axis.begin();
  Serial.println("Press the Start Button to start the machine");
  while(!axis.ready()); // Wait for start button to be pressed
  delay(1000);
  Serial.println("Initial position: " + String(axis.getPosition()));
  delay(1000);
  axis.setPosition(15);
  Serial.println("Final position: " + String(axis.getPosition()));
}
void loop() {}

See also