Skip to content

Instantly share code, notes, and snippets.

@johnmckerrell
Created January 10, 2012 17:18
Show Gist options
  • Save johnmckerrell/1590089 to your computer and use it in GitHub Desktop.
Save johnmckerrell/1590089 to your computer and use it in GitHub Desktop.
Stepper Motor Settings
#include <Stepper.h>
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 7,5,6,4);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(5);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment