I need some secure buttons that must be intentional pushed/activated

Please don’t reopen older topics.

There are many solutions, no special widgets or libraries required… just various coded methods and possibly BlynkTimer.

We don’t exist here to act as code mechanics… but post your errors here, properly formatted please, as per the Welcome Topic.

1 Like

I just have 2 buttons in push mode :wink:

hi @Gunner ,
I’m sorry for that, as my question was related to the code of them I thought it was the right place.
I try to include BlynkTimer and to test it again.

Thank you,

Ezio

don’t forget to declare

 BlynkTimer timer

Hi @Blynk_Coeur,
Thank you for the info, I’ll try and let you know.

Thank you,

Ezio

1 Like

A simple slider set with a range of 0-1 & Send on Release works just like a spring loaded toggle or slide switch.

1 Like

Hi @Gunner,
your code is not perfect…:smiley: I’m joking! :wink:
I would like to have just 10% of your knowhow of Blynk programming, however this is wath I did.
Your code switch to "True" just moving the slider up to 51% even without reaching the end and doesn’t come back if you move it below the 50%, it stay there.
What I did is, adding 1 decimal to the Slider Widget in order to have also values between 0 and 1, in this way it will be "True" only if it reache the end and comes back if you leave it in whatever position.

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "1234567890abcdefg0987654321";   // blynk-cloud.com

BlynkTimer timer;

WidgetLED redLed(V1);  // LED Widget

BLYNK_WRITE(V0) {  // Slider as "secure" Button - Set 0/1, Decimals #.# and Send on Release ON
  float slided = param.asFloat();
  if (slided == 1) {                // The slider is at the end
    digitalWrite(D4, 1);            // Open the Garage
    redLed.on();
    timer.setTimeout(500L, []() {   // non-blocking delay timer
      Blynk.virtualWrite(V0, 0);    // Resets Slider LOW
      Blynk.syncVirtual(V0);        // Processes Button "release"
      digitalWrite(D4, 0);          // Reset the Relé
      redLed.off();
    });  // END delay timer
  } else {
    if (slided >0 && slided <1) {   // The slider has been moved
      Serial.println(slided);
      Blynk.virtualWrite(V0, 0);    // Resets Slider LOW
      Blynk.syncVirtual(V0);        // Processes Button "release"
    }
  }
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk-cloud.com", 80);
  //Blynk.begin(auth, IPAddress(1,2,3,1), 8080);
  // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example

  pinMode(D4, OUTPUT);           // set pin 4 as output for Relé
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

I tested the code of @Blynk_Coeur too but yours is more what I was looking for.
Try it out, it seems a real Sliding Button now. :smile:

It’s a workaround and it works fine, but if the Blynk Staff will include a Widget in the App, people don’t have to program a lot and nobody will ask again for a “Secure Button” or, even worse, reopen old posts like I did.:joy::rofl::joy:

Thank you so much,

Ezio

1 Like

Only one Secure Button to controll all blynk widgets :rofl:
autolock after 10 "

Video_00460

3 Likes

hi @Blynk_Coeur,
that’s very useful for some applications, you really have great ideas!
I think that the code must be very complicated.

Ezio

1 Like

very very easy, I was inspired by @Gunner :wink:

//**************  lock unlock master button *********************
BLYNK_WRITE(V48) { 
Unlock = param.asInt();
timer.setTimeout(10000L, []()  // 10 secs to lock again
{
  Unlock = 0;
  Blynk.virtualWrite(V48, LOW);
});  // END Timer Function
}

//**************  Widgets to lock *********************
BLYNK_WRITE(V15) {  //slider1 to lock
if (Unlock == 0) {
  Blynk.virtualWrite(V15, Value1 );
} else {
  Value1 = param.asFloat();
  }
}

BLYNK_WRITE(V16)   { //slider2 to lock
if (Unlock == 0) {
  Blynk.virtualWrite(V16, Value2);
} else {
  Value2 = param.asFloat();
   }
}
4 Likes

Very elegant.

Pete.

thank you very much Peter :blush:

1 Like

Yes, you are right, it’s very simple and clear even for me. :grin:
Thank you for the info, I will save it for future projects.

Ezio

2 Likes

Dear Alexis, from Blynk GUI part of the system, what exactly we need? I mean which widget and what adjustments?
Many THANKS!

Hi Mike,

V48 is a styled button “in push” mode
V15 is a slider in “send on release” mode

is it what you need ? :thinking:

You have also V16?

1 Like

@Blynk_Coeur’s code could be adapted to almost any of the input widgets. You just basically have each of the corresponding BLYNK_WRITE() commands follow the format.

I agree that it is pretty clever indeed. And quite simple.

2 Likes

Yes V16 is a slider too
You can lock buttons or any input widgets.

1 Like

Blasphemy :stuck_out_tongue: … I worked long hard minutes to come up with that :rofl::rofl:

Yes, it was quick and dirty… Getting around the 51% is just a matter of stretching out the range, but only reacting to the final value. And same with moving less than 50% as an else value could activate return to 0.

EDIT - Oops, now I look at your code :blush: and see you already did similar to all that. Good job :+1:
That use of the #.# was sooo simple… I am stealing that for my code examples :wink:

PS, Sooo many options with code… and on that note :stuck_out_tongue_winking_eye:

I don’t find code a workaround, rather it is ultimate customisable control :sunglasses: If I ever learn to code quality App GUIs I would be self sufficient. But for now Blynk is by far the best to work with overall.

2 Likes

@Blynk_Coeur Ohh, nicely done… it is like the switches automatically saying “Nope, don’t want to do that”

1 Like