Segmented Switch how it works

then the operation that I intended to do does not work, or at least for my knowledge it is difficult to do it. the problem is that there are no projects based on this widget, we can turn a lamp on and off, but integrating a control option is difficult. my project was to select two segments and run either one or the other. if I’m out of the house the alarm is active if there is an anomaly me the notification, if I’m at home I turn off the alarm. but with this widget it is not possible. Thank you for the effort and help you gave me

I think the problem is that you’re relying too much on examples to give you the code that you’re looking for.
For a project of this type, you’re never going to find off the shelf code that fits your requirements 100%. Whilst its true that examples will get you headed in the right direction and show you how to do various operations, you still need to have the skills to piece these segments of code together into a workable solution.

@Blynk_Coeur has given you some fairly substantial pieces of code (something I generally tend not to do, as I think can be counterproductive) but you’re still no closer to understanding how to achieve your goal. This tells me that you need to work on your coding skills, in particular how to use variables a flags to use throughout your code.

You’ve fixated on the need to use a segmented switch to mimic the layout in the screenshot. In reality, as you only have two possible states (at home, or away) any type of switch widget could be uses as they all provide a binary state (0/1, on/off, yes/no, home/away) switching function.

You should be using the switch to set a Boolean flag (at home - true or at home = false). You then use that flag throughout your code. (if alarm is activated and at home = true then do this, else do that).

I’d suggest that you take one of the simple sketch builder examples (say the example to turn an LED on or off), get it working then add-in m,ore functionality with hand-crafted code. Use flags to perform functions - for example if the LED is on and a slider widget is set to less than 100 then light a second LED.
You’ll learn much km,ore doing this, and be better equipped to build, and more importantly maintain, your code.

Pete.

2 Likes

all is possible to do with Blynk

but you have to learn before.
my project will be finished soon.
I can control all my house with blynk and a NodeMCU at 2$, include HVAC and lights .
:wink:

thank you @PeteKnight :wink:

I thank you all for the advice you are giving me, I will try to modify the code and implement my knowledge more with the code. thank you all

1 Like