Huh, seems someone did something similar already using accelstepper and Blynk slider. I only had to make minor changes to the code based on what I learned from this thread.
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <AccelStepper.h>
#define FULLSTEP 4
#define HALFSTEP 8
// Motor pin definitions
#define motorPin1 D5 // IN1 on the ULN2003 driver 1
#define motorPin2 D6 // IN2 on the ULN2003 driver 1
#define motorPin3 D7 // IN3 on the ULN2003 driver 1
#define motorPin4 D8 // IN4 on the ULN2003 driver 1
// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxxxx";
char pass[] = "xxxxxxxx";
int maximo;
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
delay(10);
stepper.setMaxSpeed(1000.0);
delay(10);
stepper.setSpeed(200);
delay(10);
while (Blynk.connect() == false) {
}
}
BLYNK_WRITE(V0) // Max slider value is 400 for FULLSTEP and 800 for HALFSTEP. If value is too high, the motor will seize.
{
int vel = param.asInt();
maximo = vel;
stepper.setSpeed(maximo);
}
void loop()
{
Blynk.run();
stepper.runSpeed();
}
This is great since 28BYJ-48 Stepper Motor with ULN2003 seems to be one of the most common combos of the Arduino world. I’ll do a short write-up later, but this post should show up in search if someone searches for this combo and Blynk.