#include <Stepper.h>
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
int button = 13;
String ready = "";
int prevMillis = millis();
void setup() {
myStepper.setSpeed(60);
Serial.begin(9600);
pinMode(button, INPUT);
}
void loop() {
if(digitalRead(button) == HIGH){
if(ready == "start"){
ready = "clock";
}else{
ready = "anticlock";
}
prevMillis = millis();
}
if(ready == "clock"){
int currentMillis = millis();
if(currentMillis - prevMillis < 2000){
myStepper.step(-stepsPerRevolution);
}else{
ready = "";
}
}
if(ready == "anticlock"){
int currentMillis = millis();
if(currentMillis - prevMillis < 2000){
myStepper.step(stepsPerRevolution);
}else{
ready = "start";
}
}
}