#define BLYNK_TEMPLATE_ID "TMPL2i2rDOS6K"
#define BLYNK_TEMPLATE_NAME "Stepper"
#define BLYNK_AUTH_TOKEN "8xCtNylg9AYlazpqKlA659P8oSaFsGzc"
#include <AccelStepper.h>
#include <BlynkSimpleEsp32.h>
const char auth[] = "8xCtNylg9AYlazpqKlA659P8oSaFsGzc"
const char ssid[] = "Wokwi-GUEST";
const char pass[] = "";
const int stepsPerRevolution = 2048;
#define IN1 18
#define IN2 19
#define IN3 22
#define IN4 23
#define buttonClockwisePin V1
#define buttonCounterclockwisePin V2
AccelStepper stepper(AccelStepper::HALF4WIRE, IN1, IN3, IN2, IN4);
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
stepper.setMaxSpeed(500);
stepper.setAcceleration(100);
}
void loop() {
Blynk.run();
stepper.runSpeed();
}
BLYNK_WRITE(buttonClockwisePin) {
int buttonClockwiseState = param.asInt();
if (buttonClockwiseState == HIGH) {
stepper.setSpeed(500);
stepper.enableOutputs();
Serial.println("Clockwise");
} else {
{
stepper.setSpeed(0);
stepper.disableOutputs();
Serial.println("Motor Stopped");
//}
}
}
BLYNK_WRITE(buttonCounterclockwisePin) {
int buttonCounterclockwiseState = param.asInt();
if (buttonCounterclockwiseState == HIGH) {
stepper.setSpeed(-500);
stepper.enableOutputs();
Serial.println("Counterclockwise");
} else {
sePin) == LOW) {
stepper.setSpeed(0);
stepper.disableOutputs();
Serial.println("Motor Stopped");
//}
}
}