Objects of the Stepper class store the physical properties of a stepper motor and the pins it is connected to. The target position of a a stepper object is used by the StepControl class to actually move the motor. Stepper objects also maintain a step counter which reflects the current motor position. Writing to the step counter is possible to set the counter to zero (or some offset) at the home position.
Construction
Constructs a stepper object with the given pin numbers for STEP and DIR signals
Setup Functions
Sets the maximum speed of the motor in steps/s.
Sets the maximum acceleration of the motor in steps/s².
Sets the polarity of the generated step pulses. setStepPinPolarity(HIGH)
generates active high pulses. setStepPinPolarity(LOW)
generates active low pulses.
Use this function to change the polarity of the generated direction signal. setInverseRotation(true)
sets the DIR pin to LOW if the motor runs in ‘upward direction’
// you can use the standard interface for setup
motor_1.setAcceleration(5000);
motor_1.setMaxSpeed(10000);
// ...or a fluent interface
motor_2
.setAcceleration(20000)
.setMaxSpeed(15000)
.setInverseRotation(true)
.setStepPinPolarity(LOW);
Motor Positioning
Sets the target position in steps. To actually move the motor, use one of the controller objects
Sets the target position relative to the current position. To actually move the motor, use one of the controller objects
Sets the internal step counter to the parameter counterValue
. This function is NOT setting a new target position. Typically, you only use this function after homing to set the counter to zero or some offset value.
Returns the current position of the stepper.