Skip to content

Instantly share code, notes, and snippets.

@niftydevelopment
Created October 17, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niftydevelopment/f9e6f7775f1d1afb7be3 to your computer and use it in GitHub Desktop.
Save niftydevelopment/f9e6f7775f1d1afb7be3 to your computer and use it in GitHub Desktop.
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