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

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

#1

hi @Blynk_Coeur and @steve1,
sorry to open this post again but I have the same problem, I need some secure buttons that must be intentional pushed/activated.
I tried your code but it give me a lot of compiling errors.
Can you add the libraries to include, the variable declarations and where to put your code, if inside the setup loop or where.
Do I need to use a special widget in the Blynk App or just buttons?

thank you in advance,

Ezio

1 Like

Confirmation on certain buttons
#2

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

#3

I just have 2 buttons in push mode :wink:

0 Likes

#4

hi @GunnerTechTools ,
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

0 Likes

#5

don’t forget to declare

 BlynkTimer timer
0 Likes

#6

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

Thank you,

Ezio

1 Like

#7

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

#8

Hi @GunnerTechTools,
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

#9

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

Video_00460

3 Likes

#10

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

#11

very very easy, I was inspired by @GunnerTechTools :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

#12

Very elegant.

Pete.

0 Likes

#13

thank you very much Peter :blush:

1 Like

#14

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

#15

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

0 Likes

#16

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:

0 Likes

#17

You have also V16?

1 Like

#18

@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

#19

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

1 Like

#20

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