Cheers for the reply Robin2, I had managed to get the example working before I started trying to make adjustments.
Took out the strings and have made the checks just look for single character commands, also have tried implementing string compares, but I think I may be screwing up the syntax of them a little bit. I haven't done a lot of work with sending data via serial monitor before, but will read the sites and threads you sent over, thanks for that.
#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()
{
while (Serial.available())
{
inBuffer = Serial.read();
}
//byte incomingByte = Serial.read();
if (strcmp(inBuffer,"a")==0)
{
Serial.println("test point 1");
//if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
stepper1.run();
}
else if (strcmp(inBuffer,"b")==0)
{
Serial.println("test point 2");
//if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
stepper2.run();
}
//inBuffer = "";
}
Is this the correct way of doing the strcmp or does it need to be done this way?
result = strcmp(example1, example2);
if (result == 0)
For the moment, I just want to get to the point where sending "a" makes stepper one move, and sending "b", makes stepper two move. Although, in the future I will need to be able to send the number of steps so will give example 3 a look.
Thanks for the help!