Syntax
void step(
    int number_of_steps
);
ContentsIndex
PreviousUpNext
Stepper::step Method
Stepper Class | Example
Syntax
void step(
    int number_of_steps
);
Description

Rotates stepper motor at the speed set in setSpeed.

Parameters
Parameters 
Description 
int number_of_steps 
Steps of stepper motor. Positive value means rotating in one direction; negative value means rotating in the opposite direction. 
Returns

None.

Example
 #include <Stepper.h>
  
 #define STEPS 100   // Set up by particular stepper motor.
  
 // The 4-pin stepper motor, connecting 4 pins.
 Stepper stepper(STEPS, 8, 9, 10, 11);
  
 int prev = 0;       // Reserve the previous value.
   
 void setup()
 {
   stepper.setSpeed(40);      // Sets up rotation speed to 40 RPMs.
 }
   
 void loop()
 {
   int value = analogRead(0); // Gets data from the sensor.
   stepper.step(value- prev); // The movement.
   prev = value;              // Records the previous displacement.
 }
File

Stepper.h

Class