My issue is that I can't rotate the motors continuously. If I press any button, motor.step will be executed and then it stops, even though I didn't release the button.
This is my project so far.
Code:
#include <AFMotor.h>
//define steppers
AF_Stepper motor1(48, 1);
AF_Stepper motor2(48, 2);
char data;
void setup()
{
motor1.setSpeed(200); // 10 rpm
motor2.setSpeed(200); // 10 rpm
Serial.begin(9600);
}
void loop()
{
Serial.println(data);
if (Serial.available())
{
data = Serial.read();
if (data == 'A')
{
motor1.step(200, FORWARD, DOUBLE);
}
if (data == 'B')
{
motor1.step(200, BACKWARD, DOUBLE);
}
if (data == 'C')
{
motor2.step(200, FORWARD, SINGLE);
}
if (data == 'D')
{
motor2.step(200, BACKWARD, SINGLE);
}
if (data == 'E')
{
delay(50);
}
}
}
