I have a 1.8 deg. 200 step unipolar motor set up in Bi-polar mode(using 4 wires) 200 oz-in with a 36V 4A power supply. I trimmed the code down to moving the motor at the press of a button.
#include <Stepper.h>
Stepper tableSlider = Stepper(200, 5, 6);
const int button = 2; // pin button is on
int val = 0; // current button state
int old_val = 0;
int state = 0;
unsigned long previousMillis = 0;
void setup() {
pinMode(button, INPUT_PULLUP);
tableSlider.setSpeed(200); // table slide
}
void loop() {
val = digitalRead(button); // read input value and store it
unsigned long currentMillis = millis(); //check for current time
//give time for debouncing
if (currentMillis - previousMillis >= 100) {
if ((val == LOW) && (old_val == HIGH)) {
state = 1 - state; // change the state
}
previousMillis = currentMillis; // save the last time the button was ptressed
old_val = val; // val is now old, let's store it
}
if (state == 1) {
tableSlider.step(-1600); //slide table in
state = 0;
}
}