Working with Blynk app and stepper motors for the first time
I am unable to control the motor. I also dont have much experience in coding and also couldn’t find much help regarding this project on internet. Hence, the code typed below is generated by ChatGPT. I would be really grateful if somebody helps me out with this or teaches me how to do the coding for this project . I have mentioned every detail of the project below.
• Hardware Used : Nema 17 Stepper Motor, A4988 Driver and NodeMCU.
• Communication type : WiFi using Blynk App ( Version - 3.5.1 (0) )
• Smartphone OS (iOS 16.3.1)
• Blynk Library version : 1.2.0
• Sketch Code:
#include <BlynkSimpleEsp8266.h>
#include <AccelStepper.h>
// Define the pins for the stepper motor
#define dirPin D2
#define stepPin D1
#define enablePin D3
// Initialize the stepper motor
AccelStepper stepper(1, stepPin, dirPin);
char auth[] = "your_auth_token";
void setup() {
// Set the enable pin as an output
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
// Set the stepper motor properties
stepper.setMaxSpeed(1000);
stepper.setAcceleration(500);
// Connect to Blynk
Blynk.begin(auth, "NAYAK", "whitetiger065");
}
void loop() {
Blynk.run();
}
BLYNK_WRITE(V1) {
// This function will be called every time the button widget in V1 is pressed or released
int value = param.asInt();
if (value == 1) {
digitalWrite(enablePin, HIGH); // Enable the driver
stepper.move(1000); // Move the stepper motor 1000 steps
stepper.runToPosition(); // Wait for the stepper motor to finish moving
digitalWrite(enablePin, LOW); // Disable the driver
}
}