Wednesday, 26 April 2017

Arduino Turntable > ShutterStream 4 Joe.


#include <AccelStepper.h>
AccelStepper stepper(4,3,5,4,6);
String Read,AValue;int maxsteps = 400;

void setup() {
  Serial.begin(9600);
  stepper.setMaxSpeed(1000.0);stepper.setAcceleration(100.0);stepper.setSpeed(200);}

void loop() {
  if (Serial.available() > 0 ) {Read = Serial.readString();
          if (Read.equals("c"))stepper.moveTo(0);
          if (Read.equals("p"))stepper.moveTo(maxsteps);      
          if (Read.equals("v"))Serial.println("Zcapture Pro - 123456");
          if (Read.equals("o"))stepper.setCurrentPosition(0);
          if (Read.equals("r"))stepper.moveTo(0);
          if (Read.equals("l"))stepper.enableOutputs();
          if (Read.equals("u"))stepper.disableOutputs();          
          if (Read.substring(0, 1).equals("x")) {
              AValue = Read.substring(1, 5);
              stepper.moveTo(AValue.toInt());
              while (stepper.distanceToGo() != 0)stepper.run();
              Serial.println("Steps for Shot - Completed");}}
  if (stepper.distanceToGo() == 0){stepper.disableOutputs();}else{stepper.run();}
}

No comments:

Post a Comment