Created
January 10, 2014 21:44
-
-
Save cangevine/8363273 to your computer and use it in GitHub Desktop.
Stepper motor example
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
| // Wiring configuration to the stepper driver: yellow & red, gray & green | |
| #include <Stepper.h> | |
| const int STEPS_PER_REV = 200; | |
| Stepper _stepper(STEPS_PER_REV, 12, 13); | |
| const int pwmA = 3; | |
| const int pwmB = 11; | |
| const int brakeA = 9; | |
| const int brakeB = 8; | |
| void setup() { | |
| pinMode(pwmA, OUTPUT); | |
| pinMode(pwmB, OUTPUT); | |
| pinMode(brakeA, OUTPUT); | |
| pinMode(brakeB, OUTPUT); | |
| digitalWrite(pwmA, HIGH); | |
| digitalWrite(pwmB, HIGH); | |
| digitalWrite(brakeA, LOW); | |
| digitalWrite(brakeB, LOW); | |
| // Trying to look up information on max & min RPMs. | |
| // Datasheet on this website leads me to guess it's 53... | |
| // http://motion.schneider-electric.com/downloads/quickreference/NEMA17.pdf | |
| _stepper.setSpeed(53); | |
| } | |
| void loop() { | |
| _stepper.step(STEPS_PER_REV); | |
| _stepper.step(-STEPS_PER_REV); | |
| delay(100); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment