Hi everyone ,i want to control nema17 via bluetooth hc-05 with A4988 , but i cannot control motor via bluetooth , please help me
Sketch_bb.pdf (611.2 KB)
const int dirPin = 2;
const int stepPin1 = 3;
const int stepall = 20000;
void setup()
{
// Declare pins as Outputs
Serial.begin(9600);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void loop()
{
if (Serial.available()>0)
{
String D = Serial.readString();
if (D == "left")
{
digitalWrite(dirPin, LOW);
for (int i = 0; i < stepall; i++) {
digitalWrite(stepPin , HIGH);
delayMicroseconds(5000);
digitalWrite(stepPin , LOW);
delayMicroseconds(5000);
}
} else if (D == "right")
{
digitalWrite(dirPin, HIGH);
for (int i = 0; i < stepall; i++){
digitalWrite(stepPin , HIGH);
delayMicroseconds(5000);
digitalWrite(stepPin1, LOW);
delayMicroseconds(5000);
}
}
}
}
```!