Hello, I would like if possible to control 1 motor with a wemos d1, mention that the engine is connected to the L298, I need to control direction and speed by blynk? i am a novice, please help
even know if it is possible
@Iordan_Gheorghe shouldn’t be a problem with all the different widgets available with Blynk. You just need to learn how to do it without Blynk first, then learn what each of the available widgets do and decide which ones are most suitable for your project.
thanks for the reply, can you give me directions where to look?
@Iordan_Gheorghe not as friendly as the Blynk forum but plenty of useful stuff on the WeMos forum at https://forum.wemos.cc/
Thank you very much, I hope to get along
wow, the wemos-forum seems to be a pretty… lets call it “quiet” community
Well I don’t have a wemos board but I use my esp e12 boards using the arduino IDE.
So maybe that`s where you should start:
If you just want to finish this one project, then follow this link direct after the first one:
Otherwise start playing around with some arduino tutorials or examples like the blink sketch.
I managed to make the connection, I tried whit succes a scrip that every second change direction, but do not know how to realize the program that allows me to control the direction from the Internet.
Then? where are you stuck?
As I remember L298 is a bridge “amplifier”, where changing direction is made by swapping two pins, i.e. (for example)
CLOCKWISE: digitalWrite(D0, true); digitalWrite(D1, false);
CCLOCKWISE: digitalWrite(D0, false); digitalWrite(D1, true);
setting both the same: digitalWrite(D0, false); digitalWrite(D1, false); “turns on” braking (it stops immediately, depending on inertia of course)
Now all you have to do is to connect these two situation with, lets say a button. In examples you have it explained - you have to assign CLOCKWISE for “on” case, and CCLOCKWISE for “off” case. A button passes parameter [0], which is (can be now) 0, when OFF, and for example (and by default) 1 when ON. This is in example too
Got an idea of using slider for that, with middle position (+/- few counts for ease of setup) being the stop position and the rest can control PWM (software PWM in ESP) for speed control. But that needs a little coding, hope you will get into it.
Marvin, Thank you very much, my problem is the code, I have no idea to realize code
this i think you are right
@Iordan_Gheorghe have you seen the typical code for a button?
Assume button is on V0 and in PUSH (not Switch mode), something like this in ESP Standalone sketch:
BLYNK_WRITE(V0){ // which means READ the state of virtual pin 0
int btnV0 = param.asInt();
if(btnV0 == 1){
digitalWrite(D0, true);
digitalWrite(D1, false);
}
else{
digitalWrite(D0, false);
digitalWrite(D1, true);
}
}
I’ll try and come back with info
oh, the switch will work as well, for sure. This will switch the direction (and start the motor if it is off). Now @Iordan_Gheorghe just add another button, this time it SHOULD be in PUSH mode, for switching off engine:
BLYNK_WRITE(V1){ // which means READ the state of virtual pin 1
int btn = param.asInt();
if(btn == 1){
digitalWrite(D0, false);
digitalWrite(D1, false);
}
}
The above code by @Costas (and me - with second button) will (almost) for sure work, BUT it is NOT “production code”! But good to start with sth. Good luck!