i am trying to control a stepper motor via BT but I am trying to make it so if i input "1" the motor will continue moveing until i change value to 0.
it is not working like i want it too now cause when ever i press 1 it spins then stops and waits for a value.
what are you guy's suggestions?
#include <Stepper.h>
#define STEPS 200
Stepper stepper(STEPS, 4, 5, 6, 7);
int value_bluetooth = 0;
void setup()
{
Serial.begin(9600);
Serial.println("Stepper test!");
// set the speed of the motor to 30 RPMs
stepper.setSpeed(60);
}
void loop()
{ if (value_bluetooth==0) {
Serial.println("enter value: ");
while (Serial.available()==0){
}
value_bluetooth = Serial.parseInt();
Serial.println( value_bluetooth );
delay (1000);
}
{
if (value_bluetooth== 1 ) {
Serial.println("forward");
stepper.step(STEPS);
value_bluetooth = 0;
}
delay (1000);}
if (value_bluetooth== 2 ) {
Serial.println("backward");
stepper.step(-STEPS);
value_bluetooth = 0;
}
delay (1000);
{
if (value_bluetooth== 0 ){
Serial.println("stop");
stepper.step(0);
}
}
}