When using a virtual pin to start the instructions
Switching the push / switch button mode does not occur.
I understand that I rewrite the registers and understand that this should be so.
but what to do ?
There are no assignments for a single button of several pins in BLYNK, there is no merging of the buttons either.
And you need to control the engines in push mode.
Bring a piece of sketch that I use.
I had to edit your post to correct the posted code for proper viewing, as shown in the Forum’s Welcome Topic…
As for you question… well… I didn’t understand your question But it seems you are unsure of what a virtual pin is, and how to use it. So here is a link to the Blynk Help Pages; It and other great resources are available at the upper right of this page.
Question.
How to make 2 engines (4 driven pins) work on a virtual button in push mode
(Hold the button, the engines spin in the right direction, release-stop).
Add a button widget, tie it to a virtual pin, say V1.
Then add the corresponding blynk write function that reacts to your button press.
BLYNK_WRITE(V1)
{
// 1 while held 0 on release
int btnValue = param.asInt();
// do if statements
//add your digitalWrites to the pins connected to your peripherals.
}
It does not work because you are missing logic in your writes.
When you push a button, no matter the buttons state, you will always do the same digital writes. You need an if statement that takes care of your button release that stops everything.
Push mode works like this, when you push and hold a button, BLYNK_WRITE is called and executed once, when you release said button it is called again.
And I recommend putting those BLYNK_WRITE() commands in a timed loop, so that you don’t block Blynk’s internal function, Blynk.run(), and end up disconnecting your device by holding a button down for more that a second or two.
The following problem arose.
When the first button is operated in push mode, pressing the second button disrupts the operation of the first button until it is pressed again
That is, the button one remains pressed but the command does not pass from it, you need to release it and press the button again.
You would need to add more logic and commands to make your motor control offer widget “feedback”, state change, etc.
e.g. If you are using the buttons in switch mode, then when one button is pressed “on” you could add commands for the other buttons to change their state to “off” via Blynk.virtualWrite(vPin, 0). Or just set the buttons to momentary mode. either way you might also want to include logic that prevents conflicting actions when multiple buttons are pressed.
I pressed the button 1-completed the set of commands.
Pressed button 2 (button 1 did not release) performed the command set of button 2-released button 2 (button 1 pressed).
Why is not reading and executing the buttons 1? Why in order to make it work I need to release it and press again?
There are no conflicts, one of the four pins from 0 to 1 and vice versa.
How to fix it.
Thanks for the help.
This is just a suggestion… messy code and untested, but should give you something to work with…
BLYNK_WRITE(V1)
{
if (param.asInt() == 1)
{
Blynk.virtualWrite(V20, 0); // sets other button V20 to OFF
Blynk.virtualWrite(V21, 0); // sets other button V21 to OFF
Blynk.virtualWrite(V22, 0); // sets other button V22 to OFF
digitalWrite(EN1, HIGH);
digitalWrite(EN2, HIGH);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, HIGH);
}
else
stopAll();
}
So… research and experiment until it works. You are not providing any commenting in your code, so I just randomly picked a function to show how you might do something.
We (other Blynk users) are generally not here to write each others code, more like offer suggestions, tips and tricks, share ideas, guidance, etc.
Have you searched this forum for other topics using robot, car, motor control and other key words? If not, try it… there are lots of them, many with code snippets
PS. Instead of only using buttons with hard stops and starts, try sliders or the joystick widget, and appropriate motor controller code, to vary the Left/Right motor speeds to accomplish rolling turns.
Change the speed and smoothly manage it easily.
In the code for this there are 2 servo to them are connected esc and
Everything works in two directions and at different speeds.
On two virtual pins with different widgets.
I want to deal with L293D.
Searches unfortunately do not give anything.
Thanks for the advice.