Created
October 17, 2015 04:39
-
-
Save niftydevelopment/f9e6f7775f1d1afb7be3 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
int stp = 13; //connect pin 13 to step | |
int dir = 12; // connect pin 12 to dir | |
int a = 0; // gen counter | |
void setup() | |
{ | |
pinMode(stp, OUTPUT); | |
pinMode(dir, OUTPUT); | |
} | |
void loop() | |
{ | |
if (a < 200) //sweep 200 step in dir 1 | |
{ | |
a++; | |
digitalWrite(stp, HIGH); | |
delay(10); | |
digitalWrite(stp, LOW); | |
delay(10); | |
} | |
else | |
{ | |
digitalWrite(dir, HIGH); | |
a++; | |
digitalWrite(stp, HIGH); | |
delay(10); | |
digitalWrite(stp, LOW); | |
delay(10); | |
if (a>400) //sweep 200 in dir 2 | |
{ | |
a = 0; | |
digitalWrite(dir, LOW); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment