Hello all, new to the forum but I have been lurking for a while and trying to learn as I go.
I have run into an issue where I would love to have some advice.
In this project I would like to drive a stepper using the Eazydriver a pre-determined number of steps and once that line of code is executed, if need be drive the stepper another but different pre-determined number of steps using an input to start the movement.
Is this even possible?
I have tried several different approaches to accomplishing this goal but seem to fall short every time.
Below is an example of the test code.
Thank You in advance!
#define DISTANCE 384
#define DISTANCE2 24
int StepCounter = 0;
int StepCounter2 = 0;
int Stepping = false;
int Singlestepping = false;
void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
pinMode(3, INPUT);
pinMode(4, INPUT);
}
void loop() {
if (digitalRead(3) == LOW && Stepping == false)
{
Stepping = true;
}
else if (digitalRead(4) == LOW && Singlestepping == false)
{
Singlestepping == true;
}
if (Stepping == true)
{
digitalWrite(9, HIGH);
delay(10);
digitalWrite(9, LOW);
delay(10);
StepCounter = StepCounter ++; 1;
if (StepCounter == DISTANCE)
{
StepCounter = 0;
Stepping = false;
}
if (Singlestepping == true)
{
digitalWrite(9, HIGH);
delay(10);
digitalWrite(9, LOW);
delay(10);
StepCounter2 = StepCounter2 ++; 1;
if (StepCounter2 == DISTANCE2)
{
StepCounter2 = 0;
Singlestepping = false;
}
}
}
}