#include <Stepper.h>
const int stepsPerRevolution = 2000;
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
const int buttonPin = 2;
const int relayPin = 3;
int buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(relayPin, OUTPUT);
myStepper.setSpeed(10);
Serial.begin(9600);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.println("Button pressed, relay and motor is on");
digitalWrite(relayPin, HIGH);
myStepper.step(stepsPerRevolution);
} else {
Serial.println("Button not pressed, relay and motor is off");
digitalWrite(relayPin, LOW);
}
delay(50);
}