Last active
May 6, 2017 18:39
-
-
Save giantmolecules/867b12317d676a81586d0cd93ad18db4 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
/* | |
Define STEP and DIRECTION PINS like: | |
#define STEP_PIN 1 | |
#define DIR_PIN 2 | |
at the start of the main program. | |
Put the function below at the end of the main program. | |
When you want to move, call move(steps, direction) from the main program | |
*/ | |
void move(int steps, int direction){ | |
digitalWrite(DIR_PIN, direction); | |
for(int i = 0; i < steps; i++){ | |
digitalWrite(STEP_PIN, HIGH); //each time pin goes HIGH, moves one step | |
delayMicroseconds(2000); //delay determines speed of revolution (length of pause btwn steps) | |
digitalWrite(STEP_PIN, LOW); | |
delayMicroseconds(2000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment