#include
#include
#include
#define xSTEPS 200

Stepper xStepper(xSTEPS,7,8,9,10);

const int stepsPerRevolution = 200; // steps per revolution
const int buttonPin = 6; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
//
int previous = 0; // the previous reading from the analog input
int buttonState = LOW; // changeable status of the pushButton
char incomingByte;
int xNext = 0;
int xCurrent = 0;

void setup()
{
xStepper.setSpeed(120); // sets motor speed to 120 rpm
Serial.begin(9600);
pinMode(buttonPin, INPUT_PULLUP); // initialize the switch pin as an output
pinMode(ledPin, OUTPUT);
}


void loop() {
buttonState = digitalRead(buttonPin) == HIGH;
if (buttonState == HIGH)
{
digitalWrite(ledPin, HIGH);
xStepper.step(stepsPerRevolution);
}
else if (digitalRead(buttonPin) == LOW)
{
xStepper.step(-stepsPerRevolution);
digitalWrite(ledPin, LOW);
}
else
{
digitalWrite(ledPin, HIGH);
}
}