BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Steppermotor control with blynk


#1

Hello,

I want to control a Steppermotor with Blynk. I have an A4988 Stepper driver. In the Bynk App I have two Buttons on Virtual Pins. If I press one button the direction pin needs to be High, or low (depending on the direction) an there needs to be a PWM Signal on the Stepp pin.

I’ve made the following code. But get the error:

invalid use of member function (did you forget the ‘()’ ?)

Thanks in advance for any tipps.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "############";
char ssid[] = "###########";
char pass[] = "###########";

// defines pins numbers
const int stepPin = 0; 
const int dirPin = 2; 



void setup()
{
   // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
}
 void runter(){
    digitalWrite(dirPin,HIGH);
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
 }

 void hoch(){
  digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
 

BLYNK_WRITE(V0) 
{
  if(param.asInt == 1){     
   hoch();             
  }
}

BLYNK_WRITE(V1)  
{
  if(param.asInt == 1) {
    runter();
  }
}
void loop()
{
 Blynk.run();
}



#2

Without seeing the whole context of the error… dunno :stuck_out_tongue:

But you will not get far controlling a stepper like this… the driver will require a proper library and nearly the full MCUs attention in order to properly pulse the needed signals.

Since Blynk also needs to be running constantly in the background doing it IoT stuff, well, there can be a timing conflict.

I have worked this out with a dual MCU approach… one for running the stepper and one for overseeing the control via Blynk.

And also with a single MCU and semi-fancy timing… but it will limit the maximum rotational speed of the stepper.