I'm trying to get my button to turn my stepper motor with 10 presses of the button before switching to the next stepper motor. I have my code sorted to turn a single stepper motor to the correct degrees but unsure on how I get the button to switch to the next stepper motor can complete the same task as stepper one.
Any help much appreciated.
Code for single stepper motor below.
#include <Stepper.h>
const int buttonPin = 2;
const int stepsPerRevolution = 208;
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
int buttonState;
int lastButtonState = LOW;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 100;
void setup() {
pinMode(buttonPin, INPUT);
myStepper.setSpeed(50);
digitalWrite; Serial.begin(9600);
}
void loop() {
int reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (reading != buttonState) {
buttonState = reading;
if (buttonState == HIGH) {
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
}
}
}
lastButtonState = reading;
}