I wrote a sketch for controlling the stepper motor under the controls of the Blynk application, the sketch was compiled but there was a problem in that no control was taking place. Receipts and controls occur on virtual pins V1, V2, V3. (The problem is that nothing is controlled), please help solve the problem.
//#include <Stepper.h>
//#define BLYNK_WRITE
//#include <ESP8266WiFi.h>
//#include <BlynkSimpleEsp8266.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
Stepper myStepper(stepsPerRevolution, 1, 2, 3, 4);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "[private]";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "S30mini";
char pass[] = "12345678";
int pinData;
int pinData1;
int pinData2;
BLYNK_WRITE(V3) //Button Widget is writing to pin V1
{
int pinData = param.asInt();
}
BLYNK_WRITE(V2) //Button Widget is writing to pin V1
{
int pinData1 = param.asInt();
}
BLYNK_WRITE(V1) //Button Widget is writing to pin V1
{
int pinData2 = param.asInt();
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
// map it to a range from 0 to 100:
int motorSpeed = map(pinData, 0, 1023, 0, 100);
// set the motor speed:
if (motorSpeed > 0) {
myStepper.setSpeed(motorSpeed);
// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);
}
if (pinData1 == 1){
myStepper.step(stepsPerRevolution);
}
if (pinData2 == 1){
myStepper.step(-stepsPerRevolution);
}
}