stepsPerRevolution
which holds the number of ‘steps’ that the motor will take to complete one revolution. In our case, it’s 2038.myStepper
with the pin sequence of 8, 10, 9, 11.setSpeed()
function to set the speed that we wish the stepper motor to move and subsequently use the step()
function to tell it how many steps to rotate. Passing a negative number to the step()
function reverses the spinning direction of the motor.myStepper
with the pin sequence of 8, 10, 9, 11 (Remember the step sequence for these motors is IN1-IN3-IN2-IN4).distanceToGo
property) until it reaches the target position (set by moveTo
). Once distanceToGo
reaches zero we will move the motor in the opposite direction by changing the moveTo
position to the negative of its current position.run()
function. This is the most important function, because the stepper will not run until this function is executed.stepper1
to a thousand. We then set an acceleration factor for the motor to add acceleration and deceleration to the movements of the stepper motor.stepper2
except we’ll instruct it to move to -2038 because we want it to move counterclockwise.If statements
, one for each motor, to check how far the motors need to travel (by reading the distanceToGo
property) until they reach their target positions (set by moveTo
). Once distanceToGo
reaches zero, we will change their moveTo
position to the negative of their current position, so that they start moving in the opposite direction.run()
function.