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

Controlling 2 D/C motors with ESP8266 and stepper L9110S (HELP)

esp8266

#1

When I connect the ground wire to the pin (last connection to complete the circuit) it starts in the on position (motors running) then when I use the blynk app it only speeds up the motor but when I let go it continues running. It does this as well with the led example sketch to turn on and off the blue LED light and when I uploaded this it immediately turned the blue light on, then on the app when I clicked on it turned off. Is this because its active low ? How can I fix this!

Please let me know


#2

Well, you didn’t really give us much to guess on… what you are trying to do, how you are hooking it all up… what your code looks like, and so on.

But you can start by Googling and learning how an ESP8266 governs it’s GPIO pins on boot… Hint, not like an Arduino :stuck_out_tongue_winking_eye: Some boot HIGH, others LOW… with a few rapidly toggling between both before settling.

NOTE, this is NOT a Blynk specific issue, rather, it is normal ESP8266 behavior (and documented many times already in this forum)… Please remember to search first ask next, as recommended in the Welcome Topic.

But, like with Arduino, GPIO pin states can be can be modified at boot by code with pinMode() commands in your sketch.

https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/


#3

As for the LED… Yes, on most ESP8266 dev boards the built in LED is active LOW. Simply reverse the LOW & HIGH state settings in your Button Widget from 0 & 1 to 1 & 0

http://docs.blynk.cc/#widgets-controllers-button


#4

Sorry, let me explain more. The Arduino sketch I am using is posted below, and I uploaded pictures of the wiring that I followed. The reason I posted in the Blynk forum is because it has specific Arduino code to communicate with the widgets like using xVal = param[0].asInt(); I’ve been told the code I am using from https://jume-maker.blogspot.com/2018/10/how-to-control-stepper-motor-using.html is for a stepper motor. "DC motors run continuously in one direction or the other, while stepper motors have defined angles that it rotates up to. You would have to tweak the code and use different functions to control a DC motor (it should be easier since it’s just one direction or the other). - find the DC motor equivalent of "myStepper.step(1); " and “myStepper.step(-1);”

#define BLYNK_PRINT Serial
#include <Stepper.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = “7de4942cc7c34df9832aa18cc10b3e2e”;
char ssid[] = “Definis”;
char pass[] = “tiffany11”;

// change this to fit the number of steps per revolution
const int stepsPerRevolution = 450;

Stepper myStepper(stepsPerRevolution, 14, 12, 13, 15);

int xVal=512;
void setup() {

Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop() {

Blynk.run();

if( (xVal < 500) ){
myStepper.step(1);
delayMicroseconds(3000);
}else if( xVal > 550){
myStepper.step(-1);
delayMicroseconds(3000);
}

}
BLYNK_WRITE(V1)
{
xVal = param[0].asInt();
// int y = param[1].asInt();
}
BLYNK_WRITE(V2)
{
if( param.asInt() == 1){
xVal = 0;
}else{
xVal = 512;
}
}
BLYNK_WRITE(V3)
{
if( param.asInt() == 1){
xVal = 1000;
}else{
xVal = 512;
}
}


#5

First… please properly format all posted code as required in the Welcome Topic… or else your topic may be deleted :wink:

And as for your issue… your shown code IS for a stepper motor, NOT a DC motor… I am surprised it works at all.

But we teach about learning Blynk here NOT teaching programming… so Google for proper code and tutorials in-order to learn the differences and to understand them.