Arduino_EMBRYO_2 - setSpeed()

Sets the motor’s speed, in milliseconds, according to the time between pulses. This value is the motor’s time to make a half step. The maximum speed is 200 milliseconds and the minimum speed is 25000 milliseconds. The default speed value is 200 milliseconds.

Syntax

axis.setSpeed(speed)

Parameters

  • speed: time in milliseconds between pulses (defaults to 200)

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();
  axis.startWithoutHomming();  // Initialize the motor without homing procedure
  axis.setSpeed(7000); // The motor moves slower
  for (int i = 0; i < 20000; i++)axis.moveForward();
  delay(1000);
  axis.setSpeed(); // The motor moves in the default speed, 200 milliseconds
  for (int i = 0; i < 20000; i++)axis.moveBackward();
  delay(1000);
  axis.stop();
}
void loop() {}

See also