Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Last active April 5, 2020 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/2776e68550f046925634ed6dc486d7d8 to your computer and use it in GitHub Desktop.
Save JeffersGlass/2776e68550f046925634ed6dc486d7d8 to your computer and use it in GitHub Desktop.
#include <Stepper.h>
// change this to the number of steps on your motor
#define STEPS 180
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);
int switchpin = 4;
// the previous reading from the analog input
int previous = 0;
int currentPostion = 0;
void setup() {
// set the speed of the motor to 4 RPMs
stepper.setSpeed(5);
while (digitalRead(switchpin) == HIGH){ //homing routine
stepper.step(-1);
}
stepper.setSpeed(30);
delay(1000);
stepper.step(STEPS * 4);
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment