Created
April 30, 2017 17:14
-
-
Save varlen/df87e1339934a750be5f3cb2ec1a185f to your computer and use it in GitHub Desktop.
Código de teste para o motor de passo, girando em um único sentido
This file contains hidden or 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 <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); | |
Serial.begin(9600); | |
delay(1000); | |
} | |
void loop() { | |
digitalWrite(9, HIGH); // Enable 1 do driver | |
digitalWrite(10, HIGH); // Enable 2 do driver | |
// step one step: | |
myStepper.step(1); | |
Serial.print("steps:" ); | |
Serial.println(stepCount); | |
stepCount++; | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment