Skip to content

Instantly share code, notes, and snippets.

@eltallerdetd
Created March 9, 2019 06:07
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 eltallerdetd/d51990590dddd2e84923fb8ad87e58b9 to your computer and use it in GitHub Desktop.
Save eltallerdetd/d51990590dddd2e84923fb8ad87e58b9 to your computer and use it in GitHub Desktop.
#include <CheapStepper.h> //Importamos la libreria CheapStepper
CheapStepper stepper (8,9,10,11); //Instanciamos la libreria y asignamos los pines a utilizar
char lector; //Creamos una variable de tipo char
void setup() {
Serial.begin(9600); //Iniciamos la comunicacion serial
stepper.setRpm(12); //Seteamos las revoluciones por minuto del motor a 12
}
void loop() {
lector = Serial.read(); //Leemos lo que hay en la comunicacion serial y lo almacenamos en la varible de tipo char
if(lector == '1'){ //Si lo leido es igual a 1...
stepper.moveDegreesCW (180); //Movemos el motor 180 grados en sentido horario
delay(1000); //Esperamos 1 segundo
stepper.moveDegreesCCW (50); //Movemos el motor 50 grados en sentido antihorario
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment