Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created October 27, 2017 16:31
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 esmarr58/3c9619bc431a27c3e8d082a1ae4cdf3b to your computer and use it in GitHub Desktop.
Save esmarr58/3c9619bc431a27c3e8d082a1ae4cdf3b to your computer and use it in GitHub Desktop.
#include <AccelStepper.h>
AccelStepper stepper(1, 9, 8);//(define el tipo de control del motor,pin de paso,pin direccion)
int pos = 100;
void setup()
{
stepper.setMaxSpeed(800); //velocidad maxima permitida
stepper.setAcceleration(500);// relacion entre aceleracion/desaceleracion
}
void loop()
{
if (stepper.distanceToGo() == 0)//distancia de la posicion actual y la destino
{
delay(500);
pos = -pos;
stepper.moveTo(pos);//establece la posicion de destino
}
stepper.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment