Libraries \ Stepper

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Class

Stepper

Name

step()

Examples
#include "Stepper.h"

// change the steps variable to the number of steps on your motor
int steps = 100;

// create and attaches a stepper motor
// with 100 steps to pins 0, 1, 2 and 3

Stepper stepper(steps, 0, 1, 2, 3);


void setup()
{
  // set the speed of the motor to 20 rpms
  stepper.setSpeed(20);
}

void loop()
{
  // move 20 steps forward
  stepper.step(20);

  // move 20 steps backwards
  stepper.step(-20);
}
Description The step() method makes the stepper motor to turn specified number of steps. It can be positive or negative according to the direction.
Syntax
stepper.step(steps)
Parameters
stepper Any variable of type Stepper
steps int: the number of steps to turn.
Usage Application
Updated on July 07, 2011 11:11:51pm PDT

Creative Commons License