Created
October 27, 2017 16:31
-
-
Save esmarr58/3c9619bc431a27c3e8d082a1ae4cdf3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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