#include <Stepper.h>
// change this to fit the number of steps per revolution for your motor
const int stepsPerRevolution = 200;
// initialize the stepper library pins:
Stepper slideStepper(stepsPerRevolution, 8, 9, 10, 11);
Stepper cupStepper(stepsPerRevolution, 4, 5, 6, 7);
bool done = false;
void setup() {
slideStepper.setSpeed(15); //rpm
cupStepper.setSpeed(15); //rpm
pinMode(12, INPUT_PULLUP);
// initialize the serial port (for debugging):
Serial.begin(9600);
}
void loop() {
int value = digitalRead((12));
Serial.println(value);
if (value == 0)
{
// step one revolution in one direction:
Serial.println("cup clockwise");
slideStepper.step(stepsPerRevolution/2);
delay(2000);
// step one revolution in the other direction:
Serial.println("cup counterclockwise");
slideStepper.step(-stepsPerRevolution/2);
delay(2000);
// step one revolution in one direction:
Serial.println("slide clockwise");
cupStepper.step(-stepsPerRevolution/2);
delay(2000);
// step one revolution in the other direction:
Serial.println("slide counterclockwise");
cupStepper.step(stepsPerRevolution/2);
delay(2000);
}
done = true;
}