Skip to content

Instantly share code, notes, and snippets.

@jesu0404
Last active March 23, 2017 21:45
Show Gist options
  • Save jesu0404/1be145f460bdc1c7e4dbea9a6c0ab676 to your computer and use it in GitHub Desktop.
Save jesu0404/1be145f460bdc1c7e4dbea9a6c0ab676 to your computer and use it in GitHub Desktop.
Tells stepper motor to turn two steps clockwise and one step counterclockwise continuously.
#include <Stepper.h>
const int stepsPerRev = 200;
Stepper myStepper(stepsPerRev, 8, 9, 10, 11);
void setup() {
myStepper.setSpeed(60);
Serial.begin(9600);
}
void loop() {
Serial.println("clockwise");
myStepper.step(stepsPerRev);
delay(500);
Serial.println("counterclockwise");
myStepper.step(-stepsPerRev);
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment