Skip to content

Instantly share code, notes, and snippets.

@TarikTz
Created October 21, 2018 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TarikTz/a4ee651c453a6772a812127a98857dd4 to your computer and use it in GitHub Desktop.
Save TarikTz/a4ee651c453a6772a812127a98857dd4 to your computer and use it in GitHub Desktop.
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(AccelStepper::DRIVER, 13, 12);
int pos = 3600;
void setup()
{
stepper.setMaxSpeed(500);
stepper.setAcceleration(1000);
}
void loop()
{
if (stepper.distanceToGo() == 0)
{
delay(500);
pos = -pos;
stepper.moveTo(pos);\
}
stepper.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment