Two ports

This example is for Wiring version 1.0 build 0100+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

Stepper motor move by BARRAGAN

Demonstrates the use of the Stepper library

#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 8, 9, 10 and 11 
 
Stepper stepper(steps, 8, 9, 10, 11); 
 
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); 
}