Confirmation on certain buttons

I think you can already. If you have the switch as push type, then when you hold the button a value of 1 will be sent to the virtual pin. Then on release the value of 0 gets sent.

If you have your code check to see if the value of the virtual pin is 1 for longer than 1000 milli seconds then do something.

1 Like

Until get this feature…

And as example, you can make a reset button with a slider.

To reset the hardware you can put the slider’s values as 0 and an high number… and if you slide the control without go to the last value, that is the expected value for reset’s trigger… the slider can be set to 0 after some seconds…

1 Like

…and after confirmation, we can slide back to the 0 point with hardware. It can work like touch screen confirmation style.

Or use 3-5 Step V widgets and make something like http://www.cablematic.com/photos/cablematic2015/bj67-2.jpg

and when you get at hardware the correct values… write to 0 all Step V one more time

I’ve used the slider originally but moved to a double button press.

Looking at all the solutions here…

I guess in order of security (first being the least secure from accidentally pushing) but also in order of presentation and use (easier to harder)… This is my opinion only and does not necessarily reflect the view of others ha ha.

Double button push within 1 second (use latch button and code it to unlatch to make it more reliable, I can explain further if needed)
Push and hold the same push button for 1 second
Use a slider then require a button press to trigger
Use multiple vertical steps like a baggage code

Look here for ways that I used timers to allow multiple button presses to achieve different results.

I used two button widgets.
The first has to be pressed and held, when it is then switching the second button is activated. If the second button is pressed without the first then it has no effect.

I actually changer the colour of the second when the first is pressed, so that I know that its active.

When the second button is orange then it’s active.

Pete.

Hi @PeteKnight,
Any chance you could post your code for your two button solution? I am trying to do the same to prevent accidental activation by a single button and am getting into all sorts of knots (and errors) with if statements and Blynk_Write commands. I haven’t been able to find any similar code to modify and my coding expertise just isn’t up to it. My project is remote actuation of a valve on a rainwater flush line. I have it working fine with a single button but the additional of the second “activator” button has me stumped.

Cheers
Steve

just add a lambda function on the button to be hold down and a flag to tell the second button to lock or unlock

Thanks for the response @Blynk_Coeur. Lambda function? Sorry but I’m showing my lack of coding knowledge - not sure what you’re referring to. I have tried the following (this is just a snapshot of the complete sketch, capturing the action of the activator and actuator buttons)

 void myTimerEvent()
{
//If activator button is pressed, set button pin to high or low depending on button state, otherwise do nothing 
  BLYNK_WRITE(V5){
  if (Activatorbtn == 1){
  digitalWrite(btnpin, param.asInt()); // Sets btnPin HIGH or LOW depending on state of Button Widget.
  Serial.print("Btnpin:");
  Serial.println(btnpin);
  }
}
else
  Serial.print("Btnpin:");
  Serial.println(btnpin);

The Activatorbtn is the virtual button to be held down to activate (connected to virtual pin V6). The actuator button (conntected to virtual pin V5) sets btnpin high or low. btnpin is connected to digital pin 12 on the board.

Cheers
Steve

something like that

BLYNK_WRITE(V6) {  // button to be held down to activate
  if (param.asInt()) {
   flag= 0;
    timer.deleteTimer(T1);
    T1= timer.setTimeout(1000L,  []() {//push 1 sec
             });  // END Timer Function
    flag= 1;
}

BLYNK_WRITE(V5) {  // actuator button 
 if (param.asInt()) {
if(flag=1){
//do something
      }
  }
}

don’t forget to return flag = 0 after the execution of do something …

as the flag is init to zero with V6 button it’s not needed, but maybe I 'm wrong :wink:

BLYNK_WRITE(V6) {  // button to be held down to activate
  if (param.asInt()) {
   flag= 0;

Hi Stevve. I use Blynk in a very different way to most people, so all of the processing of the button logic is done in Node-Red, which will be of no use to you.

However, the same thing is easy enough to do C++
Start by making sure that the ‘activator’ button is set to ‘push’ rather than ‘switch’ mode.
When it’s pressed it will fire a BLYNK_WRITE(Vx) function event. Check that. ‘1’ has been received from the button and set an ‘active’ flag. If a ‘0’ is received (button released) then clear the ‘active’ flag.

With your main button, only process the action if your active flag is true.

Pete.

it is a little strange that inside the delta type timer ( timeout ) unconditionally set flag =1 I think that this is unwonted but I am at work now with 0 free time to think deeper about…

the flag is after timeout, not inside :wink:

you must add this to detect release before 1 sec

// Button V6 has been released
  else {
    flag= 0;        // Reset the button press flag
    timer.deleteTimer(T1); // end timer
}

…better now :wink:

1 Like

I am at work, so I can not try if my code is correct :blush:

1 Like

Hi all,
Many thanks for the thoughts on this.
@PeteKnight, the logic you described is exactly what I have in my head. My challenge has been converting this to code :grinning:
@Blynk_Coeur I really appreciate you taking the time to put some code together. From what I can understand, the activator button has to be pressed for 1 sec to make it active and then then pressing the actuator button (while still holding the activator button down) will result in an action. Is this correct? Could this be simplified? For me, the chances that both buttons are pressed simultaneously are pretty low. The logic I was thinking of was (setting the activator button to push mode in Blynk) was that, if the activator button state = 1 (ie pressed) then write the state of the actuator button to the digital pin, otherwise the activator button state must be zero and do nothing. Would this work and how would it be coded?
I’ll give your code a try and see how I go.

Cheers
Steve