First, have you made sure that the software will rotate your motor in both directions? Once you have confirmed that, change the "else" statement to another "if" to reverse the motor depending on the value of "SensorValue2".Hi Keith,
}
void loop()
{
SensorValue1=analogRead(A0);
SensorValue2 =analogRead(A1);
if(SensorValue1<500) {
stepper1.moveTo(-300);
stepper1.setSpeed(600);
stepper1.run();}
else {
stepper1.moveTo(300);
stepper1.setSpeed(600);
stepper1.run();}
This would only be for one of the sensors, but it dosent seem to be working, The motor just rotates in the same direction not matter what the input. I also think that this is the wrong way to go about coding this. Maybe something with switchstates might be better. Would you have any advice on this ?
Thank you.
Rory
p.s. For some reason when I call serial.print the motor slows down significantly. Very perculiar