Skip to content

Instantly share code, notes, and snippets.

@varlen
Created April 30, 2017 17:15
Show Gist options
  • Save varlen/f9934315326fd42900e865d4f7442d45 to your computer and use it in GitHub Desktop.
Save varlen/f9934315326fd42900e865d4f7442d45 to your computer and use it in GitHub Desktop.
Teste para motor de passo, girando 50 passos num sentido depois 50 no sentido contrário
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 2, 3, 4, 5);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// initialize the serial port:
myStepper.setSpeed(300);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
delay(1000);
}
void loop() {
digitalWrite(9, HIGH); // Enable 1 do driver
digitalWrite(10, HIGH); // Enable 2 do driver
// 50 passos:
while
myStepper.step(50);
delay(500);
myStepper.step(-50);
delay(3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment