Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass

JeffersGlass/motorDoWhile.ino Secret

Last active Apr 5, 2020
Embed
What would you like to do?
#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
You can’t perform that action at this time.