#include <AccelStepper.h>
//Amount of input-pins from stepper motor
int noOfInputPins = 4;
//Button input pin
int inputPin = 7;
//Class instance of stepper motor
AccelStepper stepMotor = AccelStepper(noOfInputPins, 8, 10, 9, 11);
void setup() {
// put your setup code here, to run once:
pinMode(inputPin, INPUT_PULLUP);
Serial.begin(9600);
//Stepper Motor
stepMotor.setMaxSpeed(1000.0);
stepMotor.setAcceleration(400.0);
stepMotor.setSpeed(800.0);
}
void loop() {
//Stepper motor logic
stepMotor.moveTo(120);
stepMotor.runToPosition();
// This halts the Arduino for one second
delay(1000);
stepMotor.moveTo(0);
stepMotor.runToPosition();
delay(1000);
// Button logic
int inputValue = digitalRead(inputPin);
if (inputValue == LOW) {
Serial.print("Input is 0: ");
Serial.println(inputValue);
delay(8000);
}
}