Thanks again for the help, in its current state, each time I send an 'a' or a 'b', it moves the respective stepper motor by one step. Although, as you can probably tell from the code, I am trying to get them to do full rotations not just single steps.
I am guessing the issue is due to the stepper1.run() and stepper2.run() being inside an IF statement, so only incrementing by a single step each time. I am unsure of how to rectify this though, how can I take them out of the IF and still keep the check in place?
#include <AccelStepper.h>
AccelStepper stepper1(AccelStepper::FULL4WIRE, 5, 6, 7, 8);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 9, 10, 11, 12);
void setup()
{
Serial.begin(9600);
stepper1.setMaxSpeed(200.0);
stepper1.setAcceleration(100.0);
stepper1.moveTo(360);
stepper2.setMaxSpeed(200.0);
stepper2.setAcceleration(100.0);
stepper2.moveTo(360);
}
char inBuffer = "";
void loop()
{
if(Serial.available()>0)
{
inBuffer = Serial.read();
}
//byte incomingByte = Serial.read();
if (inBuffer == 'a')
{
Serial.println("test point 1");
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
stepper1.run();
}
else if (inBuffer == 'b')
{
Serial.println("test point 2");
if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
stepper2.run();
}
inBuffer = "";
}