Hello,
I'm working on a project and want to connect 2 Stepper nema 17 with my bluetooth HM-10 device. I setted it up and it work with the standart code. Now I want to connect them and need to have 3 stages. One where it turns clockwise, one where it turns counterclockwise and one where it doesnt turn at all. I think I setted it up like this and it might work(exept the ''doesnt turn'' part), but I dindnt had a chance to test it, because its a school project. Anyway here is the code can please someone please check it , make sure it works and add the ''doesnt turn part.
Thank yall very much.
# include "SoftwareSerial.h"
#include <Stepper.h>
SoftwareSerial BTSerial(2, 3);
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
const int stepsPerRevolution = 200;
char btDaten;
void setup()
{
BTSerial.begin(9600);
Serial.begin(9600);
while (!Serial) {;}
myStepper.setSpeed(60);
Serial.println("2 -> forward");
Serial.println("1 -> back");
Serial.println("0 -> Stopp");
}
void loop()
{
btDaten = BTSerial.read();
if (btDaten == '2')
{
BTSerial.print("forward");
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
}
else if (btDaten == '1')
{
BTSerial.print("back"); ;
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
}
else(btDaten==’0’)
{
Serial.println("nomovement");
myStepper.step( //here it has to go
}
}