looking for some help with controlling a stepper motor.
currently i am running the code below and it works fine. when i push a button the motor goes 6400 steps (1 full rev using the Big Easy Driver)
so when i push the button it executes "program"
i need the "program" to rotate 1 full rev and delay for an amount of time, repeat x# times at a button push
when i push the button
rotate 1 rev
stop 1 sec
rotate 1 rev
stop 1 sec
.
.
.
#define DISTANCE 6400
int StepCounter = 0;
int Stepping = false;
void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
pinMode(3,INPUT);
}
void loop() {
if (digitalRead(3) == LOW && Stepping == false)
{
Stepping = true;
}
if (Stepping == true)
{
digitalWrite(9, HIGH);
delayMicroseconds(100);
digitalWrite(9, LOW);
delayMicroseconds(100);
StepCounter = StepCounter + 1;
if (StepCounter == DISTANCE)
{
StepCounter = 0;
Stepping = false;
}
}
}